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

Build PDF version #24

Closed
profvjreddi opened this issue Oct 8, 2023 · 9 comments
Closed

Build PDF version #24

profvjreddi opened this issue Oct 8, 2023 · 9 comments
Labels
good first issue good starter issue for newbies maintainence quarto/git bookkeeping

Comments

@profvjreddi
Copy link
Contributor

We have never tested or built the PDF version of the eBook.

@profvjreddi profvjreddi added maintainence quarto/git bookkeeping good first issue good starter issue for newbies labels Oct 8, 2023
@Mjrovai
Copy link
Contributor

Mjrovai commented Nov 7, 2023

The PDF version can be tricky, depending on the images. A good solution is to generate it offline from the ePub quarto version using Calibre.

@profvjreddi
Copy link
Contributor Author

profvjreddi commented Nov 8, 2023 via email

@Mjrovai
Copy link
Contributor

Mjrovai commented Nov 8, 2023

The issue was that the HTML render works correctly, with all figures rendered between text sections, as written in the .qmd files, but the pdf render, by default, puts the figures in different places in the text. I found a simpler solution, adding fig-pos: "H" on the format/pdf section of _quarto.yml:

format:
  pdf:
    fig-pos: "H"

Having the nunito font files on the root is also essential in pdf format (the HTML looks for the fonts online, but not the pdf).

format:
  pdf:
    fig-pos: "H"
    resource_files:
    - fonts/*

@Mjrovai
Copy link
Contributor

Mjrovai commented Nov 9, 2023

Another issue that prevents rendering PDFs is online images (or gifs) with, for example, spaces on link names. I could render an ePub version of the book and using Calibre, convert it to PDF. I uploaded the book to TinyMLedu drive:
https://drive.google.com/file/d/18Yx4xIWAILFRbb213o4bI9aMe6TKf_55/view?usp=sharing

@Mjrovai
Copy link
Contributor

Mjrovai commented Nov 9, 2023

As additional comments,

  1. the Nunito fonts should be on root for ePub and PDF versions.
  2. Including ToC on the ePub version, Quarto generates double numbers on it (I could not take it out). One alternative is not to include the ToC and leave it to the reader (Apple Books do it automatically). This issue does not happen on the Quarto PDF version (in the PDF converted by Calibre, yes, because I used the ePub as an example).
  3. I suggest that images should be in .jpg instead .png to reduce the size of PDF and ePub versions.

@profvjreddi
Copy link
Contributor Author

profvjreddi commented Nov 9, 2023 via email

@profvjreddi
Copy link
Contributor Author

Duplicate #83 so I am closing this issue and we can resolve it in the one that @V0XNIHILI is working on.

@profvjreddi profvjreddi closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
@Mjrovai
Copy link
Contributor

Mjrovai commented Dec 20, 2023

To generate the EPUB version, the _quart.yml file should be modified, including a section epub inside format and after html:

html:
 ....

epub:
    cover-image: cover_1.png
    number_sections: true
    #toc: true
    css: 
      - style.scss
      - epub_style-light.css
    resource_files:
    - fonts/*

The toc (Table of Contents) is disabled because the numbers were duplicated on the epub version.

The file epub_style-light.css is the style-light.scss modified to include at the end of the file, the offline font reference:

    @font-face {
        font-family: 'Nunito';
        src: url('fonts/Nunito-Regular.ttf'), /* Adjust the path and filename as necessary */
             url('fonts/Nunito-Bold.ttf');    /* Add other variations as needed */
    }
     
body {
        font-family: 'Nunito', sans-serif;
    }

In the root we should have the folder fonts (unzip the attached fonts.zip and upload it to the main directory)
fonts.zip

The PDF generated by Quarto did not work (maybe is the setup in my Mac). I got this error:

Compilation failed- error
Package svg Error: File `colab-badge_svg-tex.pdf' is missing.

Alternatively, I used CALIBRE (https://calibre-ebook.com/) to convert the e-book (epub to PDF). Calibre can add page numbers and include a TOC at the end. If the 'toc:true', for epub version generation, a TOC is included at the beginning of the book, with automatic link to the pages.

@V0XNIHILI
Copy link
Contributor

@Mjrovai also see my PR #83! The svg file missing is due the fact that Inkscape is probably not on your PATH: mrpiggi/svg#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue good starter issue for newbies maintainence quarto/git bookkeeping
Projects
None yet
Development

No branches or pull requests

3 participants