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] Problems with links occur when converting to PDF #2021

Open n-okano-s-style opened 2 months ago

n-okano-s-style commented 2 months ago

Describe the bug A clear and concise description of what the bug is.

If you preview with Markdown Preview Enhanced and convert it to PDF, the links within the page will be strange. It feels like it shifts irregularly. However, during the preview stage, in-page links work fine. This issue was discovered on July 4th. It was working fine until last week. I restarted my PC and reinstalled VSCode, but it didn't work. However, even after converting it to PDF, for some reason the links within the page only work properly when opened in Adobe. After converting to PDF, in-page links did not work properly in VSCode's vscode-pdf, chrome, and edge.

Environment

irs-alba1 commented 1 month ago

I have exactly the same problem here. Tried also with older plugin versions down to 6.10 with same result. I use the MS Edge Browser as the default viewer, because this is the normal setup for my users. Preview is correct, but as soon as the Chrome (Puppeteer) PDF file is generated, the links are all wrong. Affects both auto generated toc as well as manually created links. Also the file opens not at the top but starts in the middle of a picture at page 12... I'm quite sure that this worked correctly in the past, so it is probably not the pluing's fault but some changed behavior either in chrome or edge?

n-okano-s-style commented 1 month ago

I understand the cause.

It seems to be caused by the current version of chrome when performing Preview → Export → Chrome (Puppeteer).

I was able to confirm that the links worked fine after reinstalling the previous version of chrome. Even if you reinstall the previous version of Chrome, the automatic update will revert you to a bad version.

Your only option is to lock chrome to a version or wait for a fixed version to be released.

irs-alba1 commented 1 month ago

Can you tell if it is then a conversion or a display issue? I was able to open the generated PDF correctly in FoxitReader, while both Chrome and Edge messed up all links. Or does Edge use Chrome for PDF display?

n-okano-s-style commented 1 month ago

I think it's a conversion issue.

However, depending on the PC, the link may work properly even with the same version, which is a mystery. When I passed the PDF (Link doesn't work properly) to a PC that can convert it to PDF normally, the link did not work properly.

Links work fine in Adobe, but not in browsers like Chrome or Edge. sorry. I don't know the exact cause, but it seems that a fix is ​​currently in progress. https://issues.chromium.org/issues/347674894

imudak commented 1 month ago

I wrote a similar issue in #2014.

https://issues.chromium.org/issues/347674894

The above issue in Chromium is now FIXED, so I set up Chrome Canary (129.0.6624.0) to check it. The link now jumps close to the target, but a few lines down. This problem has not been noticed yet.

irs-alba1 commented 1 month ago

Thanks for the info! I tried available updates on all browsers I used: