shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.44k stars 172 forks source link

[BUG] Table of Contents Links Jump 11 Pages Ahead in PDF #2014

Closed imudak closed 1 month ago

imudak commented 2 months ago

Description

When generating a PDF from a Markdown file using the Markdown Preview Enhanced (MPE) extension in VSCode, clicking on Table of Contents (TOC) links results in navigating to a position 11 pages ahead of the intended section.

Environment

Steps to Reproduce

  1. Create the following Markdown file:

    # Title
    
    - [Section 1](#section-1)
    - [Section 2](#section-2)
    - [Section 3](#section-3)
    
    ## Section 1
    
    Content
    Content
    Content
    ...
    Content
    Content
    
    ## Section 2
    
    Content2
    
    ## Section 3
    
    Content3
  2. Generate the PDF using MPE in VSCode:

    • Go to Export -> Chrome (Puppeteer) -> PDF.
  3. Open the generated PDF and click on any TOC link.

Expected Behavior

Clicking on a TOC link should navigate to the corresponding section in the PDF.

Actual Behavior

Clicking on a TOC link navigates to a position 11 pages ahead of the intended section.

Additional Information

If the PDF does not contain at least 11 pages, clicking the TOC links causes the PDF to crash.

Request for Assistance

Please assist in resolving this issue. If any additional information is required, feel free to contact me.

imudak commented 2 months ago

After downgrading Chrome from the latest version 126.0.6478.115 to 124.0.6367.61 on my PC, the issue no longer occurs. It seems there were some changes related to PDF handling in Chrome around version 126, which might be affecting this behavior.

imudak commented 2 months ago

It looks like fixes are progressing on the following issue in Chromium.

Page.printToPdf does not render anchor links [347674894] - Chromium

imudak commented 1 month ago

The duplicate issue is being discussed in #2021 and we would appreciate it if you could CLOSE this one.