kohheepeace / mr-pdf

Generate PDF for document website.
https://www.npmjs.com/package/mr-pdf
MIT License
128 stars 41 forks source link

Add multiple initialDocUrls to handle multiple doc sections #16

Closed kohheepeace closed 3 years ago

kohheepeace commented 3 years ago

https://github.com/kohheepeace/mr-pdf/issues/10#issuecomment-852218292

kohheepeace commented 3 years ago

Implemented and close

idontknowjs commented 3 years ago

@kohheepeace the sections are still not generated in the PDF. Please reopen this issue.

Steps to reproduce:

npx mr-pdf --initialDocsURL="https://zowe-docs.netlify.app/stable/getting-started/overview" --contentSelector="article" --paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".announcementBar_UUUQ,nav.navbar,.docSidebarContainer_3pwe,.docMainContainer_2pgU .col.col--3,footer.footer,.docItemContainer_2szM > .margin-vert--xl > .row > .col:first-child,.pagination-nav,.docsRating,.navbar__inner,.thin-scrollbar" --coverImage="https://docusaurus.io/img/docusaurus.png" --coverTitle="Zowe Documentation" --outputPDFFilename="zowe-docs.pdf"

This script is suppose to generate complete PDF for https://zowe-docs.netlify.app/ website. But only generates the first section.

kohheepeace commented 3 years ago

@covalentbond Sorry,

Use, --initialDocURLs with comma separete. Note that initialDocURLs not initialDocsURL.

--initialDocURLs="https://zowe-docs.netlify.app/stable/getting-started/overview,https://zowe-docs.netlify.app/stable/user-guide/installandconfig,https://zowe-docs.netlify.app/stable/extend/extend-zowe-overview"

But, in your document, there is a duplicate(two same section) in https://zowe-docs.netlify.app/stable/extend/extend-zowe-overview. Developing for Zowe application framework section.

So, PDF generation will loop and not finish.

idontknowjs commented 3 years ago

@kohheepeace it gives an error: error: unknown option '--initialDocURLs'

I'm running this scrpit for the two sections only:

npx mr-pdf --initialDocURLs="https://zowe-docs.netlify.app/stable/getting-started/overview,https://zowe-docs.netlify.app/stable/user-guide/installandconfig" --contentSelector="article" --paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".announcementBar_UUUQ,nav.navbar,.docSidebarContainer_3pwe,.docMainContainer_2pgU .col.col--3,footer.footer,.docItemContainer_2szM > .margin-vert--xl > .row > .col:first-child,.pagination-nav,.docsRating,.navbar__inner,.thin-scrollbar" --coverImage="https://zowe-docs.netlify.app/img/zowe-icon.png" --coverTitle="Zowe Documentation" --outputPDFFilename="zowe-docs.pdf"
kohheepeace commented 3 years ago

@covalentbond What is the log of mr-pdf -h ?

idontknowjs commented 3 years ago

It says mr-pdf: command not found?

idontknowjs commented 3 years ago

Just to tell you, --initialDocsURL= PDF is still being generated this

kohheepeace commented 3 years ago

@covalentbond

npx mr-pdf -h
Options:
  --initialDocURLs <urls>          set urls to start generating PDF from
  --excludeURLs <urls>             urls to be excluded in PDF
  --contentSelector <selector>     used to find the part of main content
  --paginationSelector <selector>  used to find next url
  --excludeSelectors <selectors>   exclude selector ex: .nav
  --cssStyle <cssString>           css style to adjust PDF output ex: body{padding-top: 0;}
  --outputPDFFilename <filename>   name of output PDF file
  --pdfMargin <margin>             set margin around PDF file
  --pdfFormat <format>             pdf format ex: A3, A4...
  --coverTitle <title>             title for PDF cover
  --coverImage <src>               image for PDF cover. *.svg file not working!
  -h, --help                       output usage information
idontknowjs commented 3 years ago

@kohheepeace here it is: Have you not updated the NPM package?

$ npx mr-pdf -h
Need to install the following packages:
  mr-pdf
Ok to proceed? (y) y
Usage: mr-pdf [options]

Options:
  --initialDocsURL <url>           set url to start generating PDF from
  --contentSelector <selector>     used to find the part of main content
  --paginationSelector <selector>  used to find next url
  --excludeSelectors <selectors>   exclude selector ex: .nav
  --cssStyle <cssString>           css style to adjust PDF output ex: body{padding-top: 0;}
  --outputPDFFilename <filename>   name of output PDF file
  --pdfMargin <margin>             set margin around PDF file
  --pdfFormat <format>             pdf format ex: A3, A4...
  --coverTitle <title>             title for PDF cover
  --coverImage <src>               image for PDF cover. *.svg file not working!
  -h, --help                       output usage information
idontknowjs commented 3 years ago

@kohheepeace Note: I'm using Docusaurus V2 here.

kohheepeace commented 3 years ago

@covalentbond sorry I'm so stupid. I forget to publish to npm. I updated and publish new version. Could you check it again ?

=> I was not stupid. I published npm correctly. I'm not sure why your npx reffer to old version.

kohheepeace commented 3 years ago

@covalentbond And if you donwload mr-pdf global, you don't need to donwload puppeteer everytime.

npm i -g mr-pdf
idontknowjs commented 3 years ago

@kohheepeace Thank you!! It worked 🚀

Feature

Because in TOC, there is just a text Table of Contents and a very long list of links.. Just before each section starts in TOC, providing sub headings will make it easy for users to read it. Something like this:

image

kohheepeace commented 3 years ago

@covalentbond glad to hear that.

I found that --excludeURLs was made to require, this option can be set to optional I think.

Okay thanks 👍

I would like to know what is the usecase of PDF in your case. Actually I'm not a fan of PDF, I'm making this PDF tools for future backup when closing document website.

idontknowjs commented 3 years ago

@kohheepeace Yes, I completely agree that 800 pages PDF can be too annoying to read. But some of our users still like to read PDF. For that we need to provide them this.

kohheepeace commented 3 years ago

But some of our users still like to read PDF. For that we need to provide them this.

@covalentbond I understand 👍

And I don't fully understand your feature requests. Do you mean having multiple TOC per section (at the beginning of section)?

idontknowjs commented 3 years ago

Have a look at this PDF: https://docs.zowe.org/stable/Zowe_Documentation.pdf

We were using a diff library to create PDF for our Vuepress website. It is having section heading as well in the TOC. Like "Getting Started", "Extend"...

I'm willing if something this could also happen.

idontknowjs commented 3 years ago

@kohheepeace did you get it?

kohheepeace commented 3 years ago

@covalentbond yes, I understand 👍 But I've lost my motivation now, so don't expect quick fix 😉 👍

idontknowjs commented 3 years ago

Yaa completely understand, it's still somewhat a feature. But can you fix the internal links issue reported at your earliest convenience, because we are planning to deploy the website publically in a few days! 😅

Were you able to figure out the reason why it was happening