CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

PrintToPDFAsync, Setting PageHeight, PageWidth no longer functioning (CEF 2623)

Open dandotevans opened this issue 10 years ago • 5 comments

On Win7, 49Pre-release (CEF 2623) Using the CEFSharp.Wpf.Example as the base. modifying the MainWindow PrintToPdfCommandBinding method

from :

var success = await browserViewModel.WebBrowser.PrintToPdfAsync(dialog.FileName, new PdfPrintSettings
                    {
                        MarginType = CefPdfPrintMarginType.Custom,
                        MarginBottom = 10,
                        MarginTop = 0,
                        MarginLeft = 20,
                        MarginRight = 10
                    });

to:

  var success = await browserViewModel.WebBrowser.PrintToPdfAsync(dialog.FileName, new PdfPrintSettings
                    {
                        MarginType = CefPdfPrintMarginType.Custom,
                        MarginBottom = 10,
                        MarginTop = 0,
                        MarginLeft = 20,
                        MarginRight = 10,
                        PageHeight = 356,
                        PageWidth =  216
                    });

results in the method hanging and occasionally crashing the subprocess.

after running, debug.log contains:

[0408/154906:ERROR:ipc_channel_win.cc(217)] pipe error: 109
[0408/154906:ERROR:ipc_channel_win.cc(217)] pipe error: 109
[0408/154906:WARNING:raw_channel_win.cc(532)] WriteFile: The pipe is being closed. (0xE8)
[0408/154906:WARNING:channel.cc(359)] RawChannel write error

An issue has been created upstream in CEF, issue added here for reference.

dandotevans avatar Apr 11 '16 10:04 dandotevans

master has been updated to 2704, please test again if you have a chance.

amaitland avatar May 29 '16 22:05 amaitland

I have tested this with release 51.0.0 and it is still an issue.

dandotevans avatar Jul 25 '16 09:07 dandotevans

Still an issue with release 55.0.0

dandotevans avatar Feb 20 '17 07:02 dandotevans

Output page size in microns.

I believe the issue is in the units of measure your passing in, 216 x 356 is tiny in microns.

The following works fine for me.

var success = await browserViewModel.WebBrowser.PrintToPdfAsync(dialog.FileName, new PdfPrintSettings
{
	MarginType = CefPdfPrintMarginType.Custom,
	MarginBottom = 10,
	MarginTop = 0,
	MarginLeft = 20,
	MarginRight = 10,
	PageWidth = 210000,
	PageHeight = 297000
});

amaitland avatar Mar 10 '17 02:03 amaitland

Thank you for pointing that out - completely missed that. modifying the scale has resolved the issues I've been seeing. pleased to see we have such high precision on our PDF page sizes :+1:

dandotevans avatar Mar 10 '17 08:03 dandotevans