Build PDF version #9

Closed
opened 2026-03-22 15:20:59 -05:00 by GiteaMirror · 9 comments
Owner

Originally created by @profvjreddi on GitHub (Oct 8, 2023).

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

Originally created by @profvjreddi on GitHub (Oct 8, 2023). We have never tested or built the PDF version of the eBook.
GiteaMirror added the area: tools label 2026-03-22 15:21:00 -05:00
Author
Owner

@Mjrovai commented on GitHub (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.

@Mjrovai commented on GitHub (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.
Author
Owner

@profvjreddi commented on GitHub (Nov 8, 2023):

Are there any pointers you can share that will help us understand this
build process you are recommending?

On Tue, Nov 7, 2023 at 3:07 PM Marcelo Rovai @.***>
wrote:

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.


Reply to this email directly, view it on GitHub
https://github.com/harvard-edge/cs249r_book/issues/24#issuecomment-1799833126,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABT6DFCAB4QWKJWOTIXZXZLYDKIHZAVCNFSM6AAAAAA5X5VMB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJZHAZTGMJSGY
.
You are receiving this because you authored the thread.Message ID:
@.***>

--
Vijay Janapa Reddi, Ph. D. |
John L. Loeb Associate Professor of Engineering and Applied Sciences |
John A. Paulson School of Engineering and Applied Sciences |
Science and Engineering Complex (SEC) | 150 Western Ave, Room #5.305 |
Boston, MA 02134 |
Harvard University | Email @.***> | Website
http://scholar.harvard.edu/vijay-janapa-reddi | Google Scholar
https://scholar.google.com/citations?hl=en&user=gy4UVGcAAAAJ&view_op=list_works&sortby=pubdate
| Edge Computing Lab https://edge.seas.harvard.edu | Schedule a Meeting
https://scholar.harvard.edu/vijay-janapa-reddi/schedule | Admin
https://scholar.harvard.edu/vijay-janapa-reddi/contact |

@profvjreddi commented on GitHub (Nov 8, 2023): Are there any pointers you can share that will help us understand this build process you are recommending? On Tue, Nov 7, 2023 at 3:07 PM Marcelo Rovai ***@***.***> wrote: > 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. > > — > Reply to this email directly, view it on GitHub > <https://github.com/harvard-edge/cs249r_book/issues/24#issuecomment-1799833126>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ABT6DFCAB4QWKJWOTIXZXZLYDKIHZAVCNFSM6AAAAAA5X5VMB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJZHAZTGMJSGY> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> > -- Vijay Janapa Reddi, Ph. D. | John L. Loeb Associate Professor of Engineering and Applied Sciences | John A. Paulson School of Engineering and Applied Sciences | Science and Engineering Complex (SEC) | 150 Western Ave, Room #5.305 | Boston, MA 02134 | Harvard University | Email ***@***.***> | Website <http://scholar.harvard.edu/vijay-janapa-reddi> | Google Scholar <https://scholar.google.com/citations?hl=en&user=gy4UVGcAAAAJ&view_op=list_works&sortby=pubdate> | Edge Computing Lab <https://edge.seas.harvard.edu> | Schedule a Meeting <https://scholar.harvard.edu/vijay-janapa-reddi/schedule> | Admin <https://scholar.harvard.edu/vijay-janapa-reddi/contact> |
Author
Owner

@Mjrovai commented on GitHub (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 commented on GitHub (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/* ```
Author
Owner

@Mjrovai commented on GitHub (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 commented on GitHub (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
Author
Owner

@Mjrovai commented on GitHub (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.
@Mjrovai commented on GitHub (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.
Author
Owner

@profvjreddi commented on GitHub (Nov 9, 2023):

Thanks Marcelo, this is very helpful.

Looks like the font size etc. are really big. Perhaps this is something we
can make a pass on at the end of the semester (~1 month) to make it render
more tightly.

On Thu, Nov 9, 2023 at 7:11 AM Marcelo Rovai @.***>
wrote:

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.


Reply to this email directly, view it on GitHub
https://github.com/harvard-edge/cs249r_book/issues/24#issuecomment-1803714970,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABT6DFHP7YSGUZNROLYHYXLYDTB6PAVCNFSM6AAAAAA5X5VMB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBTG4YTIOJXGA
.
You are receiving this because you authored the thread.Message ID:
@.***>

--
Vijay Janapa Reddi, Ph. D. |
John L. Loeb Associate Professor of Engineering and Applied Sciences |
John A. Paulson School of Engineering and Applied Sciences |
Science and Engineering Complex (SEC) | 150 Western Ave, Room #5.305 |
Boston, MA 02134 |
Harvard University | Email @.***> | Website
http://scholar.harvard.edu/vijay-janapa-reddi | Google Scholar
https://scholar.google.com/citations?hl=en&user=gy4UVGcAAAAJ&view_op=list_works&sortby=pubdate
| Edge Computing Lab https://edge.seas.harvard.edu | Schedule a Meeting
https://scholar.harvard.edu/vijay-janapa-reddi/schedule | Admin
https://scholar.harvard.edu/vijay-janapa-reddi/contact |

@profvjreddi commented on GitHub (Nov 9, 2023): Thanks Marcelo, this is very helpful. Looks like the font size etc. are really big. Perhaps this is something we can make a pass on at the end of the semester (~1 month) to make it render more tightly. On Thu, Nov 9, 2023 at 7:11 AM Marcelo Rovai ***@***.***> wrote: > 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. > > — > Reply to this email directly, view it on GitHub > <https://github.com/harvard-edge/cs249r_book/issues/24#issuecomment-1803714970>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ABT6DFHP7YSGUZNROLYHYXLYDTB6PAVCNFSM6AAAAAA5X5VMB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBTG4YTIOJXGA> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> > -- Vijay Janapa Reddi, Ph. D. | John L. Loeb Associate Professor of Engineering and Applied Sciences | John A. Paulson School of Engineering and Applied Sciences | Science and Engineering Complex (SEC) | 150 Western Ave, Room #5.305 | Boston, MA 02134 | Harvard University | Email ***@***.***> | Website <http://scholar.harvard.edu/vijay-janapa-reddi> | Google Scholar <https://scholar.google.com/citations?hl=en&user=gy4UVGcAAAAJ&view_op=list_works&sortby=pubdate> | Edge Computing Lab <https://edge.seas.harvard.edu> | Schedule a Meeting <https://scholar.harvard.edu/vijay-janapa-reddi/schedule> | Admin <https://scholar.harvard.edu/vijay-janapa-reddi/contact> |
Author
Owner

@profvjreddi commented on GitHub (Dec 5, 2023):

Duplicate https://github.com/harvard-edge/cs249r_book/issues/83 so I am closing this issue and we can resolve it in the one that @V0XNIHILI is working on.

@profvjreddi commented on GitHub (Dec 5, 2023): Duplicate https://github.com/harvard-edge/cs249r_book/issues/83 so I am closing this issue and we can resolve it in the one that @V0XNIHILI is working on.
Author
Owner

@Mjrovai commented on GitHub (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.

@Mjrovai commented on GitHub (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](https://github.com/harvard-edge/cs249r_book/files/13730989/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.
Author
Owner

@V0XNIHILI commented on GitHub (Dec 21, 2023):

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

@V0XNIHILI commented on GitHub (Dec 21, 2023): @Mjrovai also see my PR #83! The svg file missing is due the fact that Inkscape is probably not on your PATH: https://github.com/mrpiggi/svg/issues/6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#9