Page 1 of 1

Empty size value returned in GetPdfPaperSize

PostPosted: Thu May 27, 2021 2:39 pm
by smartBeaver
I try to implement a one click save as PDF button


pdfButton_ = new JButton("PDF");
pdfButton_.setFocusable(false);
pdfButton_.setAlignmentX(LEFT_ALIGNMENT);
pdfButton_.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CefPdfPrintSettings settings = new CefPdfPrintSettings();
// A4 page size
settings.page_width = 210000;
settings.page_height = 297000;
browser.printToPDF("/home/master/code/src/pdf/testy.pdf", settings, new CefPdfPrintCallback() {
@Override
public void onPdfPrintFinished(String path, boolean ok) {
}
});
}
});


However when I click it, I get this message:

[0527/153435.832646:ERROR:print_dialog_linux.cc(124)] Empty size value returned in GetPdfPaperSize; PDF printing will fail.
The default print to PDF in the menuBar of the detailed sample app works. How can this be?

Re: Empty size value returned in GetPdfPaperSize

PostPosted: Thu May 27, 2021 2:57 pm
by magreenblatt
You need to implement CefPrintHandler.getPdfPaperSize.

Re: Empty size value returned in GetPdfPaperSize

PostPosted: Thu May 27, 2021 3:02 pm
by smartBeaver
Why do I need to implement it if it works fine in the MenuBar.java? What is the difference?

Re: Empty size value returned in GetPdfPaperSize

PostPosted: Thu May 27, 2021 3:14 pm
by magreenblatt
smartBeaver wrote:Why do I need to implement it if it works fine in the MenuBar.java? What is the difference?

I'm not sure. There's a default implementation in CefPrintHandlerAdapter. Perhaps your code isn't picking that up for some reason? I suggest debugging the apps to understand the difference.

Re: Empty size value returned in GetPdfPaperSize

PostPosted: Thu May 27, 2021 3:43 pm
by smartBeaver
Oh actually the printing to pdf worked even though i had an error message lol Thank you for your answers!