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

Exporting to PDF and ePub #815

Open
kravemir opened this issue Nov 4, 2018 · 19 comments
Open

Exporting to PDF and ePub #815

kravemir opened this issue Nov 4, 2018 · 19 comments
Labels
C-new-format Category: A new rendering format

Comments

@kravemir
Copy link

kravemir commented Nov 4, 2018

Does mdBook support exporting to PDF and ePub? If not, then this is a feature request/suggestion, otherwise documentation request/suggestion.

@kravemir
Copy link
Author

kravemir commented Nov 4, 2018

I found https://github.com/lise-henry/crowbook. It might be worth it to take a look and integrate it (I'm not Rust developer). Also, that was my first google search result, there might be better tools/libraries.

@Michael-F-Bryan
Copy link
Contributor

A while back I created an alternate backend for generating EPUB documents and published it on crates.io. It's pretty rough around the corners and doesn't do any styling, but I'd be happy to help mentor people if they want to take over development.

mdbook has a pretty good plugin architecture (docs), so it's also quite possible to write your own backend if you want.

@ehuss ehuss added the C-new-format Category: A new rendering format label May 17, 2019
@XVilka
Copy link

XVilka commented Aug 16, 2019

Would be nice to have! I heard some people migrating from mdBook to another solutions, some proprietary exactly because of the missing export to PDF.

@Michael-F-Bryan
Copy link
Contributor

I'm not too involved in mdbook development these days, but if someone wants to help work on mdbook-epub I'd be happy to add them as a collaborator.

@XVilka
Copy link

XVilka commented Aug 19, 2019

There is also mdproof for generating PDFs from Markdown files. Maybe it can be integrated with mdBook?

@lbeckman314
Copy link
Contributor

lbeckman314 commented Aug 20, 2019

I'm currently working on mdbook-latex, a backend for mdbook that aims to support LaTeX and PDF exports. It's primarily built upon pulldown-cmark, Tectonic, md2pdf, and a lot of other great programs.

Here is The Rust Programming Language PDF and LaTeX files generated by mdbook-latex:

The Rust Programming Language.pdf
The Rust Programming Language.tex

On my Thinkpad x220, it took 4.757 seconds to generate the LaTeX, and 1 minute 8.62 seconds to generate the PDF (so it won't break any speed records). And there are typesetting errors aplenty that I plan to fix in future releases.


I'm very new to Rust (and programming in general), so there are a lot of things that can be improved upon (and a better alternative PDF exporter is almost certainly possible!). Pull requests, forks, and plain old copy-pasting are actively encouraged!

There is also a roadmap to the stable release for mdbook-latex.

For anyone else looking to making a PDF or LaTeX mdbook backend, mdbook-epub and crowbook are two programs that are super helpful for learning how to parse markdown or write a proper backend. The mdbook User Guide has a terrific section regarding that as well!

@XVilka
Copy link

XVilka commented Aug 20, 2019

+100500 for Tectonic. They seem to improve based on arXiv dataset testing, along with better integration with texlab.

@lbeckman314
Copy link
Contributor

That's awesome! I'll check out mdproof as well, It would be great to have the option to skip any LaTeX dependencies if you wanted a quick and simple PDF.

@XVilka
Copy link

XVilka commented Sep 30, 2019

Note, there is ongoing effort to Oxidize the Tectonic, and ditch legacy C code out of its engine. After this is done, probably better integration will be possible.

@TianyiShi2001
Copy link

That's a feature I'd definitely love to see. Currently I'm using R's Bookdown and blogdown to author books and blogs. I wish there will be similar implementations of these packages in Rust.

I'm current learning Rust, and I hope I can contribute to this feature (probably in the summer when I have a good understanding of Rust).

@heyakyra
Copy link

This is a duplicate of #88 (Support ebooks and pdf export)

@magj2006
Copy link

That's a feature I'd definitely love to see. Currently I'm using R's Bookdown and blogdown to author books and blogs. I wish there will be similar implementations of these packages in Rust.

I'm current learning Rust, and I hope I can contribute to this feature (probably in the summer when I have a good understanding of Rust).

How is progress? I'm waiting for it.

@XVilka
Copy link

XVilka commented Jun 10, 2020

@lbeckman314 I would want to donate for your efforts, and I think many others as well. Could you please setup a an account for that? GitHub Sponsors, OpenCollective, etc

@XVilka
Copy link

XVilka commented Sep 22, 2021

Since there is zero interest to support that in mdBook, I recommend a relatively new framework to create books, more flexible that commonly known Bookdown - Quarto. It's pandoc-based, thus can export to basically anything. You can see their gallery for samples how such different formats and exports look like. It's quite actively developed as well.

@HollowMan6
Copy link

Hi all! I just created a mdBook backend named mdbook-pdf for generating PDF based on headless chrome and Chrome DevTools Protocol Page.printToPDF. It depends on Google Chrome / Microsoft Edge / Chromium. The generated page are pretty much alike the one you manually printed to PDF in your browser by opening print.html or mentioned here: #88 (comment) , but with customization of PDF paper orientation, scale of the webpage rendering, paper width and height, page margins, generated PDF page ranges, whether to display header and footer as well as customize their formats, and more, as well as automation. It supports all the platform where Google Chrome / Microsoft Edge / Chromium would work. You can check samples of the generated PDF files in the Artifacts here.

@SteveBetter
Copy link

SteveBetter commented May 17, 2022

PDF format with Table of Contents is needed.

@HollowMan6
Copy link

HollowMan6 commented Dec 27, 2022

PDF format with Table of Contents is needed.

mdbook-pdf now supports Table of Content, see: HollowMan6/mdbook-pdf#1 (comment)

@LegNeato
Copy link

LegNeato commented Nov 29, 2023

I just released mdbook-typst. While it isn't 100% done, it supports PDF output with links, bookmarks, and pdf metadata.
Attached is the converted guide and a screenshot.

If you want more control, you may be interested in the other 2 projects I just released:

Converted book.pdf

Screenshot 2023-11-29 at 4 54 43 PM

@max-heller
Copy link
Contributor

I built mdbook-pandoc, a backend powered by Pandoc. Pandoc is quite mature and supports many output formats, including PDF (I've mainly tested LaTeX) and EPUB. Sample rendered PDF books are here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-new-format Category: A new rendering format
Projects
None yet
Development

No branches or pull requests