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

Inject your own content (css, footer, header, cover page) #19

Closed
Ange-Cesari opened this issue Apr 13, 2023 · 1 comment
Closed

Inject your own content (css, footer, header, cover page) #19

Ange-Cesari opened this issue Apr 13, 2023 · 1 comment

Comments

@Ange-Cesari
Copy link

Hi,
I understand that the pdf generation is dependent on mdbook html generation. Let’s say I have an "external.css" css file, which includes all my styles with the media print.

How can I make it global so every pages generated by the mdbook have this style applied? If not possible, where in the mdbook can I modify the css beforehand ?

Let’s also assume that I have a file "header.html" and a file "footer.html" which are intended to represent the header and footer I want to put to each page (globally in the whole book) . How can I integrate it?

Finally, do you think it would be possible to add a cover page to this book, from an html file that contains the necessary css?

One should foresee the possibility of links for images in these html files. For example, for the cover page we could add a company logo, in the footer, we could add a logo for documentation... So it should be able to handle not only files but sources

I think there is plenty of use in this.

I tried to make an approach with wkhtmltopdf: https://github.com/Ange-Cesari/schedariu-rs

There must be something we can do here, unfortunately it's still kinda buggy because it needs the patched version of wkhtmltopdf.

@HollowMan6
Copy link
Owner

Hi! Thank you for your questions, although most of your issues seems to be mdbook-specific, as you said, pdf generation is dependent on mdbook html generation, I will still try to help you as much as I can.

How can I make it global so every pages generated by the mdbook have this style applied? If not possible, where in the mdbook can I modify the css beforehand?

Actually I don't know if you can do that, I only know they do have themes supported. You can try to find your answer at mdBook Documentation, and if it's not possible, try to file a feature request here.

Let’s also assume that I have a file "header.html" and a file "footer.html" which are intended to represent the header and footer I want to put to each page (globally in the whole book) . How can I integrate it?

We do have header and footer template support, you can assign the corresponding file content to config. https://github.com/HollowMan6/mdbook-pdf/blob/main/test_doc/book.toml#L34-L35 However, as we just pass those parameters to Chromium https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF , I can't guarantee the rendering quality. You can file a issue at Chromium side if you are not satisfied.

Finally, do you think it would be possible to add a cover page to this book, from an html file that contains the necessary css?

Maybe, you can try to change the extension name from .html to .md and link it to your SUMMARY.md, but I don't know if the css will still work in this case. You may also wanna try to make the cover a separate book and then concatenate the cover pdf to the original book pdf.

Unfortunately, this backend relies too much on third party tools, and the purpose of this backend originally was to generate pdf books in the CI so we don't need to print manually through Chromium. I think there will be few room for us to do any customization here.

@HollowMan6 HollowMan6 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2023
@HollowMan6 HollowMan6 pinned this issue May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants