kohheepeace / docusaurus-pdf

Generate PDF for docusaurus
https://drive.google.com/file/d/19P3qSwLLUHYigrxH3QXIMXmRpTFi4pKB/view
113 stars 18 forks source link

cannot generate pdf #8

Closed garnier-quentin closed 3 years ago

garnier-quentin commented 4 years ago

Hi,

I have tried to generate a pdf but i have an error (surely me).

npx docusaurus-pdf https://docs.centreon.com/current/en/integrations/plugin-packs/procedures/applications-mail-bluemind.html 
Downloading Chromium r722234 - 121.1 Mb [====================] 100% 0.0s 

Generating PDF of https://docs.centreon.com/current/en/integrations/plugin-packs/procedures/applications-mail-bluemind.html

Error: Loading style from https://docs.centreon.com/https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"/><link rel="stylesheet" href="/current/en/css/highlight.js-9.12.0-default.min.css failed
    at DOMWorld.addStyleTag (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/node_modules/puppeteer/lib/DOMWorld.js:307:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  -- ASYNC --
    at Frame.<anonymous> (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.addStyleTag (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/node_modules/puppeteer/lib/Page.js:429:29)
    at Page.<anonymous> (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/node_modules/puppeteer/lib/helper.js:112:23)
    at /home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/lib/index.js:161:47
    at step (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/lib/index.js:33:23)
    at Object.next (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/lib/index.js:14:53)
    at fulfilled (/home/qgarnier/.npm/_npx/24785/lib/node_modules/docusaurus-pdf/lib/index.js:5:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
kohheepeace commented 4 years ago

Thanks for report 👍

This is a bug of this plugin related this line.

https://github.com/KohheePeace/docusaurus-pdf/blob/c43d2822ed37059ca05655d8add9f5f4b04906ec/src/index.ts#L29

Regex is only intended to load css from simple docusaurus website like

https://v2.docusaurus.io/docs/introduction https://redux.js.org/introduction/getting-started

I will tackle to support well customized website like yours.

Swader commented 4 years ago

We're trying to generate a PDF of the Polkadot wiki and are running into the same problem.

evangelos-ai commented 4 years ago

Is there a workaround ?

kohheepeace commented 4 years ago

@evangelos-ai the easiest approach is to upgrade docusaurus from v1 to v2.

I will try to tackle this issue this weekend.

sorry!

kohheepeace commented 4 years ago

@garnier-quentin, @Swader , @evangelos-ai Hi, could you try this one https://github.com/KohheePeace/mr-pdf ?

evangelos-ai commented 4 years ago

The outcome from the https://github.com/KohheePeace/mr-pdf looks much much better ! Thanks @KohheePeace

kohheepeace commented 4 years ago

@evangelos-ai its my pleasure and hope your star 👍

Swader commented 4 years ago

@KohheePeace amazing, works like a charm! I modified my print style a bit and now the export looks almost acceptable, only images need tweaking, but other than that, superb! Thank you for this! You got my star!

kohheepeace commented 4 years ago

@Swader yay!👍