cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.89k stars 2.92k forks source link

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

Closed dandotevans closed 7 years ago

dandotevans commented 8 years ago

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.

amaitland commented 8 years ago

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

dandotevans commented 8 years ago

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

dandotevans commented 7 years ago

Still an issue with release 55.0.0

amaitland commented 7 years ago

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
});
dandotevans commented 7 years ago

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: