useblocks / sphinx-simplepdf

A simple PDF builder for Sphinx documentations
https://sphinx-simplepdf.readthedocs.io
MIT License
32 stars 14 forks source link

Paper Size 6x9 possible? #96

Open mitja opened 7 months ago

mitja commented 7 months ago

I would like to generate a PDF file for a self-published book. A common format is 6 inches by 9 inches. Is it possible to customise the paper size with sphinx-simplepdf?

danwos commented 7 months ago

Haven't tested it, but as the PDF generation is based in weasyprint, which config is mostly done in CSS and which Sphinx-SimplePDF allows to manipulate, I would say yes :)

Just follow the docs from weasyrpint for page size and introduce the changes to Sphinx by using html_css_file in your conf.py. That should do the trick, maybe add an !important after your custom CSS attribute to overwrite the config from Sphinx-SimplePDF.

Needed CSS:

@page {
  size: 6in 9in;
}