HollowMan6 / mdbook-pdf

A backend for mdBook written in Rust for generating PDF based on headless chrome and Chrome DevTools Protocol. (用 Rust 编写的 mdBook 后端,基于headless chrome和Chrome开发工具协议生成PDF)
https://crates.io/crates/mdbook-pdf
GNU General Public License v3.0
153 stars 18 forks source link

Feature Request: support manual page breaks #22

Closed sjsadowski closed 1 year ago

sjsadowski commented 1 year ago

In some cases it makes sense to define where pages should break such as around images so that they are rendered on a single page.

This might be accomplished with

<!-- PAGE_BREAK -->

Then in the html a CSS rule could be inserted, something like

@media print {
    .pagebreak { page-break-before: after; } 
}

and then replacing the PAGE_BREAK instruction with an empty div:

<div class="pagebreak"></div>

I have been successfully using the plugin otherwise, and am happy to continue doing so - this would just be a quality-of-life improvement.

HollowMan6 commented 1 year ago

Hi! Actually, this is a duplicate issue. https://github.com/HollowMan6/mdbook-pdf/discussions/9#discussioncomment-4895678

You can just use the code mentioned to replace the <!-- PAGE_BREAK --> you used in the markdown files. And just as I mentioned in all the previous issues, pdf generation is dependent on mdbook html generation, if you prefer your method, these can get realized by mdbook directly.

sjsadowski commented 1 year ago

Got it - I searched issues not discussions, sorry for the dupe but thanks for the quick response.