vscode-markdown-pdf icon indicating copy to clipboard operation
vscode-markdown-pdf copied to clipboard

error when exporting pdf

Open QCShen opened this issue 3 years ago • 11 comments

I got an error when exporting pdf. image

This error only occurs on the version higher than v1.2.0. (on versions that prior to 1.2.1 everything is ok.)

Does anyone experience the same issue?

QCShen avatar Apr 14 '21 18:04 QCShen

This error looks a lot like this other: #185

Try following these steps: CTRL+shift+p > settings.json > add the line: "markdown-pdf.executablePath": "C:\chrome.exe" > restart vscode

fwhv2042 avatar May 10 '21 05:05 fwhv2042

Of course I've done this several times from the beginning. Error still occurred, but message changed if I set the path to chrome.exe. (I'm using Edge for default browser) image

No idea what is the read target. (temp html or chrome.exe?)

QCShen avatar May 11 '21 11:05 QCShen

OK. I'll try to debug. So, please let me know your environment.

  1. OS (Windows 10? Mac? Ubuntu?)
  2. Chome browser version
  3. Visual Studio version

And please try to make a pdf with the attached file. test.md

fwhv2042 avatar May 11 '21 14:05 fwhv2042

Thank you so much. @fwhv2042 Here is my environment. OS: Windows 10 Chrome: Always up to date (now 90) VSCode: Always up to date (now 1.56 user setup)

Trying make pdf from attached test.md also output the same error.

QCShen avatar May 11 '21 15:05 QCShen

Thank you for your information. It ’s the same environment as me. Sorry to trouble you, but I want you to try one thing.

https://github.com/yzane/vscode-markdown-pdf/blob/837ad2afd32768024f14565a3de2d24c16e9140e/extension.js#L399-L404

Please try changing the code as below. (Sorry, if it has already been done)

var options = {
          executablePath: vscode.workspace.getConfiguration('markdown-pdf')['executablePath'] || puppeteer.executablePath(),
          args: ['--lang='+vscode.env.language, '--no-sandbox', '--disable-setuid-sandbox'],
          ignoreDefaultArgs: ['--disable-extensions'],
          // Setting Up Chrome Linux Sandbox
          // https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
      };

The difference is as follows. ignoreDefaultArgs: ['--disable-extensions'],

fwhv2042 avatar May 11 '21 22:05 fwhv2042

If the above method fails, try replacing it( C:\Users\ username \.vscode\extensions\yzane.markdown-pdf-1.4.4 ) with this file and running export pdf. extension.zip

I have included an error message, so please let me know the result.

fwhv2042 avatar May 11 '21 22:05 fwhv2042

Sorry for the late response. I added the ignoreDefaultArgs option but nothing changed. I also replaced the extension.js with the one you attached, after showing 'exportHtml OK', 'launch OK' and 'newPage OK', the same error message was displayed. 'page.pdf OK' message was not displayed. image

Does this mean that the browser extensions I installed have nothing to do with this issue?

QCShen avatar May 16 '21 09:05 QCShen

I disabled the "markdown-pdf.styles" option in VSCode setting, and comment out all the options except "path" , run on your test.md, the same error occurred. test_tmp.zip

Attached is the temporary html file.

image

QCShen avatar May 16 '21 09:05 QCShen

Thank you for trying!! Probably a browser issue. I think that the markdownpdf extension is working fine. So, next step. Let me decide if it's a browser issue.

Please install Microsoft chromium edge. Microsoft chromium edge download

And please set "markdown-pdf.executablePath": C:\msedge.exe

  • Path example C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe

fwhv2042 avatar May 16 '21 22:05 fwhv2042

My default browser is "Microsoft Edge based on Chromium". All the behavior I reported above was basically based on "Microsoft Edge based on Chromium", except my 2nd post on replying to your request to setting "markdown-pdf.executablePath" to chrome.

The error is produced by puppeteer, so I tried replacing the puppeteer(which is "puppeteer-core": "^2.1.1") used in markdownpdf 1.44 with the one(which is "puppeteer": "^1.3.0") used in markdownpdf 1.2.0, and everything goes well, PDF is successfully generated. This approach also worked fine to fix the error when using markdownpdf 1.2.1 who uses "puppeteer": "^1.20.0".

It seems that the error was produced by puppeteer newer the v1.3, and I traced the puppeteer source to try to find out the reason, but nothing comes out yet (likely the timeout setting things). @fwhv2042 san, thank you very much for your help. I guess here is the wrong place to discuss. Anyway any help is welcome.

QCShen avatar May 17 '21 00:05 QCShen

Excuse me for interrupting. Should this be rolled back to markdown 1.2.1? I tried it, but I got Error: puppeteer.launch() again.

keides2 avatar Feb 28 '22 05:02 keides2