mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

feature request: Generate PDF with outlines intact

Open seanmrnda opened this issue 3 years ago • 10 comments

I think it would be awesome if we can generate PDF with outlines intact. Also a command to generate pdf with outlines intact. I hope this idea aligns with the mdbook team.

seanmrnda avatar Jun 15 '22 12:06 seanmrnda

I'm not sure what you mean by "outlines"?

ISSOtm avatar Jun 22 '22 17:06 ISSOtm

Screenshot_2022-06-23-09-19-55-31_c0fc23361849dfc0a4b4c6dd2adcac79.png

This is a screenshot I took from my pdf/ebook reader on my phone. What I meant by Outlines is exactly this. Page links with title for faster and efficient navigations within pdf/ebook files.

seanmrnda avatar Jun 23 '22 01:06 seanmrnda

I'm not sure what you mean by "outlines"?

I think the other term is "Table of Contents" ToC.

seanmrnda avatar Jun 23 '22 02:06 seanmrnda

I'm not sure what you mean by "outlines"?

Maybe adding a new keyword in output.html.print, like outline = true/false

[output.html.print]
enable = true
page-break = true
outline = true # new keyword to include the 'ToC' in pdf print.

seanmrnda avatar Jun 23 '22 02:06 seanmrnda

I see. Where should the ToC be placed? Before any chapters, or after any prefix chapters?

How should it be formatted? Simple "transposition" of the ToC list as currently rendered, or something else?

ISSOtm avatar Jun 23 '22 06:06 ISSOtm

I see. Where should the ToC be placed? Before any chapters, or after any prefix chapters?

How should it be formatted? Simple "transposition" of the ToC list as currently rendered, or something else?

Not referring to ToC placed in a page of the generated pdf. It should be in the metadata of the generated pdf. I'm not sure if the outlines are a part of the metadata, but It should be included upon generating the pdf, which will be visible inside the pdf reader.

genera

I had to manually edit the pdf outlines which was very time consuming. Why not include it upon generating the pdf?

seanmrnda avatar Jun 23 '22 06:06 seanmrnda

Considering that the PDF is generated by the browser, I don't think we have any control over this. The document outline is already provided by us via semantic HTML (h2 etc.), so I'm not sure what else we can do.

You way want to look into back-ends that directly render to PDF like mdbook-pdf, and see if those support that. That said, that specific back-end seems to use Chrome and should suffer from the same limitations, so maybe mdbook-latex may work better for this.

ISSOtm avatar Jun 23 '22 07:06 ISSOtm

Considering that the PDF is generated by the browser, I don't think we have any control over this. The document outline is already provided by us via semantic HTML (h2 etc.), so I'm not sure what else we can do.

You way want to look into back-ends that directly render to PDF like mdbook-pdf, and see if those support that. That said, that specific back-end seems to use Chrome and should suffer from the same limitations, so maybe mdbook-latex may work better for this.

okay, thanks for the insights. I'll look into those packages/libraries that you mentioned. Thanks again.

seanmrnda avatar Jun 23 '22 11:06 seanmrnda

mdbook-pdf now supports Table of Content, see: https://github.com/HollowMan6/mdbook-pdf/issues/1#issuecomment-1366157949

HollowMan6 avatar Dec 27 '22 20:12 HollowMan6