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

[Bug]: the parameter outline in page.pdf seems not work #12360

Open
1 of 2 tasks
zsq471214943 opened this issue Apr 28, 2024 · 6 comments
Open
1 of 2 tasks

[Bug]: the parameter outline in page.pdf seems not work #12360

zsq471214943 opened this issue Apr 28, 2024 · 6 comments

Comments

@zsq471214943
Copy link

Minimal, reproducible example

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    executablePath:"D:\\tools\\.local-browser\\win64-1293398\\chrome-win\\chrome.exe",
    args:["--no-sandbox","--disable-setuid-sandbox","--generate-pdf-document-outline"],
    protocol:"cdp"
  });
  const page = await browser.newPage();
  await page.goto('file://D:\\temp\\filetest\\html\\测试pdf.html', {
    waitUntil: 'networkidle2',
  });
  // page.pdf() is currently supported only in headless mode.
  // @see https://bugs.chromium.org/p/chromium/issues/detail?id=753118
   await page.pdf({
    path: 'hn.pdf',
    format: 'letter',
    outline: true,
    timeout: 0
  });

  await browser.close();
})();

Error string

no error

Bug behavior

  • Flaky
  • PDF

Background

image

Expectation

the export pdf include the toc
image_1

Reality

The result did not output as expected

Puppeteer configuration file (if used)

No response

Puppeteer version

22.7.1

Node version

20.12.2

Package manager

npm

Package manager version

10.5.0

Operating system

Windows

Copy link

This issue was not reproducible. Please check that your example runs locally and the following:

  • Ensure the script does not rely on dependencies outside of puppeteer and puppeteer-core.
  • Ensure the error string is just the error message.
    • Bad:

      Error: something went wrong
        at Object.<anonymous> (/Users/username/repository/script.js:2:1)
        at Module._compile (node:internal/modules/cjs/loader:1159:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
        at Module.load (node:internal/modules/cjs/loader:1037:32)
        at Module._load (node:internal/modules/cjs/loader:878:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
        at node:internal/main/run_main_module:23:47
    • Good: Error: something went wrong.

  • Ensure your configuration file (if applicable) is valid.
  • If the issue is flaky (does not reproduce all the time), make sure 'Flaky' is checked.
  • If the issue is not expected to error, make sure to write 'no error'.

Once the above checks are satisfied, please edit your issue with the changes and we will
try to reproduce the bug again.


Analyzer run

@OrKoN
Copy link
Collaborator

OrKoN commented Apr 29, 2024

outline parameter only works for the old headless mode (headless: 'shell') Currently Chrome does not support it.

@OrKoN
Copy link
Collaborator

OrKoN commented Apr 29, 2024

@Lightning00Blade could you please update the documentation to make sure the outline option remark properly show up on the website? Perhaps it makes sense to throw an error if it is used in the incompatible mode.

@OrKoN
Copy link
Collaborator

OrKoN commented Apr 29, 2024

@Lightning00Blade let's also file a feature request to have this feature for Chrome and not only for the headless shell.

@Lightning00Blade
Copy link
Collaborator

There is already a bug on Chromium to add support for this option: https://issues.chromium.org/issues/41387522#comment48
Please upvote that feature request as it signals interest in the feature.

@OrKoN OrKoN added upstream P3 and removed P2 labels Apr 30, 2024
@OrKoN
Copy link
Collaborator

OrKoN commented Apr 30, 2024

Looks like the feature is already implemented upstream and will likely ship with Chrome M126.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants