Skip to content
New issue

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

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

Already on GitHub? # to your account

Only getting first page #47

Closed
Cliffback opened this issue Apr 27, 2024 · 7 comments
Closed

Only getting first page #47

Cliffback opened this issue Apr 27, 2024 · 7 comments

Comments

@Cliffback
Copy link
Contributor

Me again! Trying to make a pdf of a mdbook source, and everything compiles fine, but I only get the first page and no table of contents. This is the repo: https://github.com/gbadev-org/tonc

It depends on mdbook-pandoc, mdbook-toc and mdbook-external-links.

A live server with the compiled book is up here for reference: https://gbadev.net/tonc/

Is it something wrong with my setup, or is the source perhaps not compatible with mdbook-pdf?

@HollowMan6
Copy link
Owner

Okay, thanks for letting me know the actual book behind the whole story! Now I understand why you said that the method I mentioned is not working #46 (comment) They have customized commands for those preprocessors, which actually compile the dependencies checked out as submodules (they are not depending on the binaries you mentioned directly). The mdbook-pdf Docker image doesn't have the rust toolchain to compile those submodules. The book also depends on Python, which the Docker image doesn't have as well (All of these are to reduce the image size, and these compiling environments are not typically needed for books). Hence, I don't believe those commands really work #46 (comment)

To make life easier, let's not use Docker for this case. You need to have Rust toolchain https://rustup.rs/ and Python3 installed on your machine (enough for all mdbook-pdf related stuff, and also suggested here https://github.com/gbadev-org/tonc?tab=readme-ov-file#setup).

Execute the following commands:

# Install everything locally
cargo install --git https://github.com/HollowMan6/mdbook-pdf.git
cargo install --git https://github.com/HollowMan6/mdBook mdbook
python3 -m venv venv
source venv/bin/activate
pip3 install mdbook-pdf-outline

git clone https://github.com/gbadev-org/tonc
cd tonc
git submodule init
git submodule update --recursive

Add these lines to book.toml:
image

Then, run mdbook build and you will find the outlined book at output/pdf-outline/output.pdf. I have attached a copy of what I have compiled:

output.pdf

I'll close this issue now since I don't find anything abnormal in the generated book above. Let me know if you have any other questions.

HollowMan6 added a commit that referenced this issue Apr 27, 2024
Related to #47

Signed-off-by: Hollow Man <hollowman@opensuse.org>
@HollowMan6
Copy link
Owner

I added the book you mentioned to the CI 63bd360 Now you can get the book from GitHub Actions Artifacts as well: https://github.com/HollowMan6/mdbook-pdf/actions/runs/8861938688 as well

@Cliffback
Copy link
Contributor Author

Thank you so much, that is of such a huge help. The pdf you uploaded looks good, except some cropping issues, especially when it comes to the tables. On page 16 a lot of the text in the table is cropped out, while this is not the case when doing a normal print to pdf when viewing it in Chrome.

And thanks for adding it as an artifact :D

@HollowMan6
Copy link
Owner

except some cropping issues, especially when it comes to the tables. On page 16 a lot of the text in the table is cropped out, while this is not the case when doing a normal print to pdf when viewing it in Chrome.

Theoretically, it should look the same, I guess you inherited some settings from your previous print when you printed that manually. You can always do so as well in mdbook-pdf. If text in the table is cropped out, I would suggest you fine-tune those margin settings https://github.com/HollowMan6/mdbook-pdf/blob/main/test_doc/book.toml#L31-L34, as well as the scale https://github.com/HollowMan6/mdbook-pdf/blob/main/test_doc/book.toml#L28

PS: Actually I found that the table on page 16 of the PDF generated from the CI looks good, so you might want to apply the same settings when you build your book locally https://github.com/HollowMan6/mdbook-pdf/blob/main/.github/workflows/test.yml#L228-L241 The PDF I generated out myself just use the default settings.
output.pdf

@Cliffback
Copy link
Contributor Author

I see the issue was only in the first one you linked to above, the issue went away in the build from artifacts and the one in the last comment, so all is good, thank you!

Regarding compiling, I might want to have to try on another machine, as I'm getting error: failed to run custom build command for headless_chrome v1.0.9`` when trying to install mdbook-pdf (that was why I initially went down the Docker route. I'm on arm64 macOS, not sure if it is some kind of incompatibility there

@HollowMan6
Copy link
Owner

Regarding compiling, I might want to have to try on another machine, as I'm getting error: failed to run custom build command for headless_chrome v1.0.9`` when trying to install mdbook-pdf (that was why I initially went down the Docker route. I'm on arm64 macOS, not sure if it is some kind of incompatibility there

It should be fine with builds on MacOS as the build CI passed. Anyway you can always get the binary from the CI or release: mdbook-pdf-v0.1.8-aarch64-apple-darwin

@Cliffback
Copy link
Contributor Author

Thanks, the binary did the trick!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants