Empty size value returned in GetPdfPaperSize

Having problems with building or using the JCEF Java binding? Ask your questions here.

Empty size value returned in GetPdfPaperSize

Postby smartBeaver » Thu May 27, 2021 2:39 pm

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?
smartBeaver
Newbie
 
Posts: 6
Joined: Wed May 26, 2021 7:51 am

Re: Empty size value returned in GetPdfPaperSize

Postby magreenblatt » Thu May 27, 2021 2:57 pm

You need to implement CefPrintHandler.getPdfPaperSize.
magreenblatt
Site Admin
 
Posts: 10919
Joined: Fri May 29, 2009 6:57 pm

Re: Empty size value returned in GetPdfPaperSize

Postby smartBeaver » Thu May 27, 2021 3:02 pm

Why do I need to implement it if it works fine in the MenuBar.java? What is the difference?
smartBeaver
Newbie
 
Posts: 6
Joined: Wed May 26, 2021 7:51 am

Re: Empty size value returned in GetPdfPaperSize

Postby magreenblatt » Thu May 27, 2021 3:14 pm

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.
magreenblatt
Site Admin
 
Posts: 10919
Joined: Fri May 29, 2009 6:57 pm

Re: Empty size value returned in GetPdfPaperSize

Postby smartBeaver » Thu May 27, 2021 3:43 pm

Oh actually the printing to pdf worked even though i had an error message lol Thank you for your answers!
smartBeaver
Newbie
 
Posts: 6
Joined: Wed May 26, 2021 7:51 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 5 guests