Enhance PDF viewing experience with new document viewer
- Replaced button in `Details.cshtml` with a link to a new document viewer page. - Created `DocumentViewer.cshtml` to display PDFs using an iframe, with a back button and a link to an experimental DevExpress viewer. - Introduced `DocumentViewerModel` in `DocumentViewer.cshtml.cs` for handling invoice ID and PDF URL. - Updated `OnGetAsync` in `ViewPdf.cshtml.cs` to set `Content-Disposition` to inline for better PDF rendering in the browser.
This commit is contained in:
@@ -18,7 +18,6 @@ public class ViewPdfModel : PageModel
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(int id)
|
||||
{
|
||||
// Sicherheit: defensive checks, gleiche Logik wie CustomReportStorageWebExtension
|
||||
var invoice = await _db.ZugferdInvoices
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(i => i.Id == id);
|
||||
@@ -35,6 +34,10 @@ public class ViewPdfModel : PageModel
|
||||
var bytes = await System.IO.File.ReadAllBytesAsync(invoice.ResultFilePath);
|
||||
_logger.LogInformation("ViewPdf: Invoice {Id} ausgeliefert ({Size} Bytes).", id, bytes.Length);
|
||||
|
||||
return File(bytes, "application/pdf", $"{Path.GetFileName(invoice.ResultFilePath)}");
|
||||
// Wichtig: keine "attachment" Content-Disposition setzen
|
||||
// wir setzen inline (oder lassen es weg) damit Browser im Viewer darstellt
|
||||
Response.Headers["Content-Disposition"] = $"inline; filename=\"{Path.GetFileName(invoice.ResultFilePath)}\"";
|
||||
|
||||
return File(bytes, "application/pdf");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user