Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add support for PDF headers and footers (from html files) #9463

Closed
Foitn opened this issue Nov 23, 2023 · 3 comments · Fixed by #9543
Closed

[Feature Request] Add support for PDF headers and footers (from html files) #9463

Foitn opened this issue Nov 23, 2023 · 3 comments · Fixed by #9543
Labels
pdf Produce PDF as the output format
Milestone

Comments

@Foitn
Copy link

Foitn commented Nov 23, 2023

With the old wkhtmltopdf there was the option to add html files to generate a header and footer for the pdf using the --header-html flag.
Now with the new pdf generation library (the chromium one) this option is gone.
It would be great if it were possible to add these headers from html files, in a similar fashion.
Could be the same as for the cover page, so it could look something like this:

pdf: true
pdfTocPage: true
pdfFileName: MyAmazingPdf
pdfCoverPage: articles/some-document/0-cover.html
pdfPageHeader: articles/pdf-header.html
pdfPageFooter: articles/pdf-footer.html
# Optionally even
pdfCoverPageNoHeaderFooter: true
@yufeih yufeih added the pdf Produce PDF as the output format label Nov 24, 2023
@yufeih
Copy link
Contributor

yufeih commented Nov 24, 2023

HTML header/footer templates are doable but handling of page numbers in the templates would be tricky.

@m3koenig
Copy link

m3koenig commented Feb 8, 2024

Hi, is there an example of that?
I tried this but there is not the content of the "html" file as header. Instead of this its the path to the file.

@Foitn
Copy link
Author

Foitn commented Jun 6, 2024

I have the same issue, please help me with this.
My html file is not added, only the title.

If I would add the entire html into the template.
When I try to start using it with the default footer, so something like this:
pdfFooterTemplate: <div style="width: 100%; font-size: 12px;"><div style="float: right; padding: 0 2em"><span class="pageNumber"></span> / <span class="totalPages"></span></div></div>
I get an error:
C:\Projects\<myPath>\toc.yml: error InvalidTocFile: C:\Projects\<myPath>\toc.yml is not a valid TOC File: (Line: 5, Col: 37, Idx: 138) - (Line: 5, Col: 37, Idx: 138): While scanning a plain scalar value, found invalid mapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pdf Produce PDF as the output format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants