Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blank Document Issue with PdfViewer When Printing in Firefox #61

Open
RSM-ESC opened this issue Oct 14, 2024 · 0 comments
Open

Blank Document Issue with PdfViewer When Printing in Firefox #61

RSM-ESC opened this issue Oct 14, 2024 · 0 comments

Comments

@RSM-ESC
Copy link

RSM-ESC commented Oct 14, 2024

Hi, I'm experiencing an issue with the PdfViewer:

When printing in Firefox, a blank or incorrect document is displayed. The PDF is displayed correctly in the PdfViewer itself, but when the print button is pressed, the print preview opens and shows it as blank, so that it cannot be printed. Other browsers like Chrome or Edge do not have this problem.

Through debugging, I can confirm that the uri and src in the PdfViewer are correctly passed, and the download also works. The correct src is transmitted for printing, but the document remains blank. I'm using Vaadin 23 and PdfViewer 2.7.4.

A similar issue has been reported before, with a suggested solution. I've implemented this in my code, but it hasn't resolved the the problem for me. Print buton does not work (print.js error)

Here are the code snippets:

StreamResource resource = new StreamResource("Name" + ".pdf",
    () -> new ByteArrayInputStream(byteArrayOutputStream.toByteArray())
);
verticalLayoutPDFView.removeAll();
verticalLayoutPDFView.add(PdfViewerHelper.pdfViewer(resource));
public static PdfViewer pdfViewer(StreamResource resource) {
    PdfViewer pdfViewer = new PdfViewer();
    pdfViewer.setAddPrintButton(true);
    pdfViewer.setAutoZoomOptionLabel("Autom. Zoom");
    pdfViewer.setPageFitZoomOptionLabel("Ganze Seite");
    String contextPath = VaadinRequest.getCurrent().getContextPath();
    StreamRegistration streamRegistration = VaadinSession.getCurrent().getResourceRegistry().registerResource(resource);
    String uri = contextPath + "/" + streamRegistration.getResourceUri();
    pdfViewer.setSrc(uri);
    pdfViewer.setHeightFull();
    return pdfViewer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant