getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.78k stars 959 forks source link

Feature request: render pdf from page #2646

Open leotsarev opened 1 month ago

leotsarev commented 1 month ago

Feature request

Environment

Zola version: 0.19.х

Expected Behavior

I want zola to be able to create PDF from any page. Use case that I create site with documentation, and I want user to be able to download PDF for some of pages, and me to be able to control PDF content.

I envision use case like this:

  1. There is create_pdf parameter for any page/section
  2. If "yes", zola should render given page twice - as a HTML, and as a PDF (create pagename.pdf near page/index.html)
  3. Basically, rendering PDF should be creating temporary HTML and passing it to something like wkhtmltopdf with corresponding css
  4. Zola should pass page.rendering_as_pdf parameter to templates, enabling user to add/remove content based on this parameter
  5. Zola should allow pages to reference "this" PDF by relatrive url syntax (@pagename.pdf)
  6. May be Zola should automatically create PDFs, it they are referenced by relative url and doesn't exists in static folder
  7. May be there is should be option to create PDF from section (including all pages)
ARitz-Cracker commented 1 month ago

Unsure if this is within Zola's scope and kinda sounds like an XY problem. Any particular reason why you don't want to use these?

Keats commented 1 month ago

That would be my go-to approach as well. Stuff like wkhtmltopdf are IMO not good enough so you need to have some headless browser if you want good results

leotsarev commented 1 month ago

Any particular reason why you don't want to use these?

I miss opportunity to render different content "for print/pdf" and "for html". One example would be to include subpages into content.

jamiedumont commented 1 month ago

Any particular reason why you don't want to use these?

I miss opportunity to render different content "for print/pdf" and "for html". One example would be to include subpages into content.

If you’re after included sub-pages, are on macOS or Windows and aren’t adverse to paid software, the iA Writer does a wonderful job of turning markdown into pdfs.

leotsarev commented 4 days ago

I don't like idea of having different pipelines....