Skip to content

Instantly share code, notes, and snippets.

@FilBot3
Last active January 12, 2023 14:28
Show Gist options
  • Select an option

  • Save FilBot3/57f5e040a7b138ee33023a5671c77d02 to your computer and use it in GitHub Desktop.

Select an option

Save FilBot3/57f5e040a7b138ee33023a5671c77d02 to your computer and use it in GitHub Desktop.

Revisions

  1. FilBot3 revised this gist Jun 30, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions printing-pdfs-as-booklets.md
    Original file line number Diff line number Diff line change
    @@ -54,8 +54,8 @@ Now, run the script `podman-texlive.sh mydocument.pdf` and it will convert that

    * Open the PDF viewer of choice, this can be Evince, Okular, or LibreOffice Draw.
    * Then, when printing the document, choose to print all pages, but choose the odd pages first.
    * If not using `--short-edge`, simply take the stack of paper and put it back in the paper tray without rotating it.
    * If using `--short-edge`, rotate the stack of paper and put it back into the paper tray.
    * If using `--short-edge`, simply take the stack of paper and put it back in the paper tray without rotating it.
    * If **not** using `--short-edge`, rotate the stack of paper and put it back into the paper tray.
    * In the PDF Viewer, print all even pages.

    This should print the booklet and be ready to be folded and stapled.
  2. FilBot3 revised this gist Jun 30, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion printing-pdfs-as-booklets.md
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,7 @@ podman run \
    --hostname="texlive" \
    docker.io/texlive/texlive:latest pdfbook2 \
    --outer-margin=0 \
    --inner-margin=0 \
    --inner-margin=50 \
    --top-margin=0 \
    --bottom-margin=0 \
    $@
  3. FilBot3 created this gist Jun 17, 2022.
    63 changes: 63 additions & 0 deletions printing-pdfs-as-booklets.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    # Printing PDFs as booklets

    ## Overview

    Printing a PDF as a booklet helps reduce the page count needed to print, and also make the PDF able to be travel sized. The size of where it becomes unusable is up to you. However, if it's too big to fold and staple, then you shouldn't do this.

    ## Requirements

    * Podman or Docker

    ## Setup

    This will require that the file name not include spaces. If the file does have spaces, rename it with underscores or hyphens.

    ## Usage

    ### Converting

    Pull/Download the [TexLive](https://hub.docker.com/r/texlive/texlive) Docker Image.

    ```bash
    podman pull docker.io/texlive/texlive:latest
    ```

    Now, we'll mount the current working directory into the running container and then convert the file.

    Create a script with the following contents.

    ```bash
    # podman-texlive.sh
    podman run \
    --rm \
    --mount="type=bind,src=$(pwd),dst=/workdir,shared=relabel" \
    --workdir="/workdir" \
    --privileged \
    --userns=keep-id \
    --name="texlive" \
    --hostname="texlive" \
    docker.io/texlive/texlive:latest pdfbook2 \
    --outer-margin=0 \
    --inner-margin=0 \
    --top-margin=0 \
    --bottom-margin=0 \
    $@
    ```

    This will execute `pdfbook2` from the TexLive suite in the container. It will remove any margins that the application adds by default. By default, `pdfbook2` will make the odd pages face down or normal, and even pages will be face up or upside down. This makes printing easier with single-side printers without having to rotate the pages.

    Including the `--short-edge` flag will make `pdfbook2` make all the pages face the same way. Using this method, you'll need to rotate the stack of papers before printing on the other side.

    Now, run the script `podman-texlive.sh mydocument.pdf` and it will convert that PDF into a booklet PDF.

    ### Printing

    * Open the PDF viewer of choice, this can be Evince, Okular, or LibreOffice Draw.
    * Then, when printing the document, choose to print all pages, but choose the odd pages first.
    * If not using `--short-edge`, simply take the stack of paper and put it back in the paper tray without rotating it.
    * If using `--short-edge`, rotate the stack of paper and put it back into the paper tray.
    * In the PDF Viewer, print all even pages.

    This should print the booklet and be ready to be folded and stapled.

    You may need to modify the margins or fit to page settings of the PDF Viewer's printing preferences as it may add MORE margin that you don't want. I recommend print previewing, or only print 2 to 4 pages so you're not wasting a lot of paper.