Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: PrintToPDF and print preview requires additional PrintCompositorLPAC config in M125+ #3725

Closed
binarynate opened this issue Jun 27, 2024 · 11 comments
Labels
bug Bug report windows Windows platform

Comments

@binarynate
Copy link

Describe the bug

First, I want to say that I love CEF and hugely appreciate your immense amount of work on it. Thank you! I recently upgraded from CEF 111 to 125 and discovered that CefBrowserHost::PrintToPDF() now silently fails on Windows (it works correctly on macOS). By silently fails, I mean that the PDF is not created and the CefPdfPrintCallback isn't invoked. I then tested the Windows 64-bit builds of the cefclient application and found that starting with CEF 125, the "Print to PDF" option from the Tests dropdown fails silently, too (i.e. the PDF is not created and it doesn't show a UI dialog indicating that the PDF was created). Here are are findings testing with different versions of cefclient:

  • cefclient 124: Tests -> "Print to PDF" works
  • cefclient 125: Tests -> "Print to PDF" fails silently
  • cefclient 126 stable and 127 beta: Tests -> "Print to PDF" fails silently

Do you have any ideas for how I can resolve this issue? The debug.log file for cefclient 125 doesn't appear to have any details about the error:
debug.log

To Reproduce
Steps to reproduce the behavior:

  1. Download and run the cefclient sample app for CEF 125 or newer.
  2. Click Tests -> "Print to PDF"
  3. Observe that the PDF is not created and there is no UI dialog indicating that the PDF was created.

Expected behavior
The PDF is created and cefclient displays a UI dialog confirming that the PDF was created.

Versions (please complete the following information):

  • OS: Windows 10
  • CEF Version: 125.0.19 (observed with any version of CEF >= 125)
@binarynate binarynate added the bug Bug report label Jun 27, 2024
@magreenblatt magreenblatt added the windows Windows platform label Jul 1, 2024
@edgardogho
Copy link

Does it fail on every page? can you access www.google.com and generate a PDF out of it?
I had the same issue on CEF 126 (Linux) and some pages failed to generate the PDF and others would work (google for instance would work but pages containing google ads would fail).

@binarynate
Copy link
Author

Does it fail on every page?

Yes, it fails on every URL that I try.

can you access www.google.com and generate a PDF out of it?

No, this fails. It also fails for other URLs I have tried, such as https://news.ycombinator.com

@magreenblatt
Copy link
Collaborator

Works fine for me in M126 and M127 on Windows 11.

  1. Run cefclient.exe
  2. Click Tests -> "Print to PDF"
  3. The "output.pdf" file is created successfully.

cefclient 126 stable and 127 beta: Tests -> "Print to PDF" fails silently

What version, specifically, did you test? Are you passing any command-line flags to cefclient?

@magreenblatt magreenblatt added the needs user feedback Additional feedback required label Jul 5, 2024
@binarynate
Copy link
Author

binarynate commented Jul 8, 2024

Thank you for investigating this, Marshall. I just tested again with 126.2.10+g61241e4+chromium-126.0.6478.127, which I downloaded by going to the CEF builds page and clicking the link next to "Sample Application" from the "Current Stable Build" section for Windows 64-bit. I tested it on both Windows 11 and Windows 10 and found that the "Print to PDF" option failed for both. I didn't pass any command-line flags and am running cefclient.exe by double-clicking it. I attached a video from demonstrating this on Windows 11:

demo.mp4

If there's any additional info that would be helpful for me to send, please let me know.

@magreenblatt
Copy link
Collaborator

magreenblatt commented Jul 8, 2024

Thanks for the additional details. I can reproduce the issue with the 126.2.10 and 127.0.8 official Sample Application but not with a local CEF M127 build (Debug or Release). This suggests that the issue may be related to variations (features) that are enabled or disabled for non-Official builds only. This is what I see in chrome://version/ for my local M127 Debug build that appears PDF or printing-related:

OutOfProcessPrintDriversPrint:Enabled_20230912
PdfOcrDesktop:Enabled
PdfOutOfProcessIframe:Enabled

However, running the Official M127 build with --enable-features=EnableOopPrintDrivers,PdfOopif doesn't appear to help.

Here is the comprehensive list of M127 variations that are enabled in my working build in case someone wants to do a more exhaustive test of various feature flags to identify the culprit.

@magreenblatt magreenblatt removed the needs user feedback Additional feedback required label Jul 8, 2024
@magreenblatt
Copy link
Collaborator

PDF-related features (at M127) can be found here, and print-related features can be found here.

@magreenblatt
Copy link
Collaborator

Running cefclient with --enable-logging=stderr --v=1 shows the following after PrintToPDF:

[297668:292520:0708/141223.900:ERROR:sandbox_win.cc(840)] Sandbox cannot access executable. Check filesystem permissions are valid. See https://bit.ly/31yqMJR.: Access is denied. (0x5)

This error does not appear with the local Release build so it's likely related.

@magreenblatt
Copy link
Collaborator

magreenblatt commented Jul 8, 2024

This fixes PrintToPDF and print preview for me in official M126 and M127: --disable-features=PrintCompositorLPAC

@magreenblatt
Copy link
Collaborator

magreenblatt commented Jul 8, 2024

This can also be fixed by correctly setting permissions via icacls. See the related Chromium issue here. This is the preferred solution, and the same as Google Chrome's installer.

@magreenblatt magreenblatt changed the title PrintToPDF() silently fails on Windows starting in CEF 125 windows: PrintToPDF and print preview requires additional PrintCompositorLPAC config in M125+ Jul 8, 2024
@magreenblatt
Copy link
Collaborator

See either of the above solutions.

@magreenblatt magreenblatt closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2024
@binarynate
Copy link
Author

Thank you so much for pinpointing this, Marshall! This resolved the issue for me. I truly appreciate your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report windows Windows platform
Projects
None yet
Development

No branches or pull requests

3 participants