Skip to content

Blank Document Issue with PdfViewer When Printing in Firefox #61

Open
@RSM-ESC

Description

@RSM-ESC

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions