-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Question] Is it possible to set AlwaysOpenPdfExternally #3509
Comments
OK, after many hours of searching in the last 48 hours for a solution to this, I think I've managed to discover something soon after posting here that works. Would anyone mind taking a look at this solution and seeing if it's going to cause me any unexpected problems? For each run: const tmpDir = fs.mkdtempSync(`/tmp/pwtest`);
fs.mkdirSync(`${tmpDir}/userdir/Default`, { recursive: true });
const defaultPreferences = {
plugins: {
always_open_pdf_externally: true,
},
}
fs.writeFileSync(`${tmpDir}/userdir/Default/Preferences`, JSON.stringify(defaultPreferences));
const context = await chromium.launchPersistentContext(`${basePath}/userdir`, { acceptDownloads: true }); This seems to work and forces the browser to download files vs displaying them in the in-browser PDF viewer. I just want to make sure I'm not shooting myself in the foot by only having a tiny preferences file to start (although it gets filled-in on first start). |
You could also |
can you pls give us example code with page.route tnx a lot! |
It seems like the workaround from this comment solves the issue. |
I hit the same problem today and the way I resolved it is by adding a
|
@waynerobinson a slight variation, instead of setting user data you can set the preferences file in chromium args: e.g.
There's a basic preferences file here: https://support.google.com/chrome/a/answer/187948 |
Can we reopen this issue because it is still unsolved? |
We have another issue where we keep track of it here #7822. |
do you have a python version of the workaround? |
Hi!
On creation of a browser or context (permanent or otherwise), is it possible to set the config value
AlwaysOpenPdfExternally
or the equivalentplugins.always_open_pdf_externally
preference?I've tried a kludgy solution that has me navigate to
chrome://settings/content/pdfDocuments
on load and click the option. But we need to use Chromium in headless to export PDFs of pages as well as download PDF files that the browser always opens in its embedded viewer… and there seems to be no way of getting the actual PDF content out of that viewer.Any help would be appreciated.
Cheers, Wayne
The text was updated successfully, but these errors were encountered: