kohheepeace / docusaurus-pdf

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

Generate PDF fail for `2.0.0-beta0` #29

Open ywjr opened 3 years ago

ywjr commented 3 years ago

npx docusaurus-pdf http://localhost:3000/platformintro/intro intro.pdf

Error: The src attribute of the 'styles*.js' file could not be found! at getScriptPathFromHTML (C:\Users\lenovo\AppData\Roaming\npm-cache_npx\5804\node_modules\docusaurus-pdf\lib\index.js:100:15) at C:\Users\lenovo\AppData\Roaming\npm-cache_npx\5804\node_modules\docusaurus-pdf\lib\index.js:164:42 at processTicksAndRejections (internal/process/task_queues.js:93:5)

antonygibbs commented 3 years ago

Probably needs updating for Docusaurus 2.0.0-beta0?

ywjr commented 3 years ago

Sorry, I can't link to GitHub now. I can't reply  you directly  

Sorry, I can't link to GitHub now. I can't answer you directly

I have tested 2.0.0-beta.0 and 2.0.0-alpha.73, and the test results are as follows

  1. PDF file can be generated on 2.0.0-alpha.73,

2。 However, it failed to run on 2.0.0-beta.0. It can't generate PDF. The failure information is like the above post.

------------------ 原始邮件 ------------------ 发件人: "kohheepeace/docusaurus-pdf" @.>; 发送时间: 2021年5月18日(星期二) 晚上9:58 @.>; @.**@.>; 主题: Re: [kohheepeace/docusaurus-pdf] generate PDF fail (#29)

Probably needs updating for Docusaurus 2.0.0-beta0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ywjr commented 3 years ago

Sorry, I can only reply by mail now。

I suggest another function:

Multiple MD files are merged and generated into a PDF file

------------------ 原始邮件 ------------------ 发件人: "kohheepeace/docusaurus-pdf" @.>; 发送时间: 2021年5月18日(星期二) 晚上9:58 @.>; @.**@.>; 主题: Re: [kohheepeace/docusaurus-pdf] generate PDF fail (#29)

Probably needs updating for Docusaurus 2.0.0-beta0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ywjr commented 3 years ago

------------------ 原始邮件 ------------------ 发件人: "kohheepeace/docusaurus-pdf" @.>; 发送时间: 2021年5月18日(星期二) 晚上9:58 @.>; @.**@.>; 主题: Re: [kohheepeace/docusaurus-pdf] generate PDF fail (#29)

Probably needs updating for Docusaurus 2.0.0-beta0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

idontknowjs commented 3 years ago

I've been facing the same issue - is there any soultion to it?

kohheepeace commented 3 years ago

@covalentbond, @ywjr Are you using docusaurus v1? This npm will create a PDF file for v1.

@antonygibbs Thanks 👍

idontknowjs commented 3 years ago

Thanks @kohheepeace - But I've been using the latest version 2.0.0-beta.0 only.

image

kohheepeace commented 3 years ago

I've noticed @ywjr have written it already.

@covalentbond I've confirmed that https://github.com/kohheepeace/mr-pdf works correctly for v2 beta. Could you also check if mr-pdf works ? I will merge the code of mr-pdf to docusaurus-pdf.

Just run the below command.

 npx mr-pdf --initialDocsURL="https://docusaurus.io/docs" --paginationSelector=".pagination-nav__item--next > a"

📌 [Issue Fix Outlook]

kohheepeace commented 3 years ago

@covalentbond And docusaurus-pdf cannot generate PDF for homepage. https://zowe-docs.netlify.app/ is homepage not docs page.

ywjr commented 3 years ago

    the test results are as follows

  1. PDF file can be generated on v2.0.0-alpha.73,

2。 However, it failed to run on v2.0.0-beta.0. It can't generate PDF. 

The failure information is like the above post.

------------------ 原始邮件 ------------------ 发件人: "kohheepeace/docusaurus-pdf" @.>; 发送时间: 2021年5月19日(星期三) 下午5:56 @.>; @.**@.>; 主题: Re: [kohheepeace/docusaurus-pdf] generate PDF fail (#29)

@covalentbond, @ywjr Are you using docusaurus v1? This npm will create a PDF file for v1.

@antonygibbs Thanks 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

kohheepeace commented 3 years ago

@ywjr Hey, please write the issue properly as possible as you can. It distracts me from reading and dealing with issues. 😠

idontknowjs commented 3 years ago

@kohheepeace mr-pdf worked for v2.0.0-beta.0 site. Thank you! 🙌

My concern is I've swizzled the DocItem component as you may find here. While generating the PDF these components are also being printed:

  1. image
  2. image

Is there any way - we can prevent it

kohheepeace commented 3 years ago

@covalentbond yes!😀 You can exclude unnecessary HTML elements by using --excludeSelectors

npx mr-pdf ... --excludeSelectors=".docsRating"

Is this working ?

idontknowjs commented 3 years ago

@kohheepeace thanks it worked! 🎉

antonygibbs commented 3 years ago

@kohheepeace Thanks so much for pointing out mr-pdf. I was able to get great PDF documentation from the command line npx mr-pdf --initialDocsURL="http://localhost:3000/docs/{starting-page}" --paginationSelector=".pagination-nav__item--next > a", but found that this included the 'Edit this page' icon and link. I was unable to determine how to exclude this in the parameter --excludeSelectors. Are you able to help on that detail? (I found that all other exclusions I needed happened by default 😃)

kohheepeace commented 3 years ago

@antonygibbs You can use chrome devtools to detect the CSS class for 'Edit this page' icon and link.

But... there is no specific Class for this element... image

Is this one working ?

--excludeSelectors=".margin-vert--xl a"

(I found that all other exclusions I needed happened by default 😃)

=> Yes, I've also noticed this. Maybe docusaurus added CSS for print PDF by default. => Or, Maybe Chrome Api has changed.

antonygibbs commented 3 years ago

@kohheepeace That totally worked! Thank you so much for responding to this thread today to offer assistance to us all, and the alternative of mr-pdf is great for some other teams here too, I am spreading the word!

ACavdar commented 2 years ago

... . I was able to get great PDF documentation from the command line npx mr-pdf --initialDocsURL="http://localhost:3000/docs/{starting-page}" --paginationSelector=".pagination-nav__item--next > a", but ....

@antonygibbs How can this command work? The command you passed above has parameter --initialDocsURL, but documentation of mr-pdf gives; --initialDocURLs (note the location of letter s) . I am really confused, help me out here. @kohheepeace @antonygibbs . The command works with parameter described in the documentation; --initialDocURLs .

I use Docusaurus 2.1.0 (tried with 2.0 beta versions first) and need to generate PDF from the documentation but, below is my adventure with no luck.

npx mr-pdf --initialDocsURL="http://localhost:3000/docs/intro" --paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".margin-vert--xl a"

error: unknown option '--initialDocsURL'

------------------------------

npx mr-pdf --initialDocURLs="http://localhost:3000/docs/intro" --paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".margin-vert--xl a"

error: required option '--contentSelector <selector>' not specified

-------------------------------

npx mr-pdf --initialDocURLs="http://localhost:3000/docs/intro" --paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".margin-vert--xl a" --contentSelector="article"

-- result: PDF generated. Only first page (intro) 

The CSS selector for next page link has also changed in 2.0 versions. It was .pagination-nav__item--next but now it is .pagination-nav__link--next .

I would appreciate your help to generate PDF with all pages in my Docusaurus documentation project.

ACavdar commented 2 years ago

@idontknowjs :

Thanks @kohheepeace - But I've been using the latest version 2.0.0-beta.0 only.

image

I, too get the same error, and also with href instead of src sometimes. Did you manage to find a solution for that? I used Docusaurus versions 2.0.0-beta.14 and 2.1.0.

RiNaPa commented 2 years ago

Is there any way I can generate pdf of site on button click instead of command line?