Skip to content

Commit

Permalink
[fix] restore page number count, remove extra pdf copies (#92)
Browse files Browse the repository at this point in the history
* restore ordering, remove extra copies

* remove copy, not the actual textbook
  • Loading branch information
ashmchiu authored Sep 9, 2024
1 parent 611ac14 commit 539f457
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/generate-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
mkdir -p pdf_numbering_output
num_pages=$(pdftk textbook_full_original.pdf dump_data | grep NumberOfPages | awk '{print $2}')
sed -i "s/194/$num_pages/" pdf-generation/numbering.tex
sed -i "s/161/$num_pages/" pdf-generation/numbering.tex
# Don't continue if the sed failed
if [ $? -ne 0 ]; then
Expand All @@ -148,26 +148,28 @@ jobs:
fi
pdflatex pdf-generation/numbering.tex
pdftk pdf-generation/numbering.pdf burst output pdf_numbering_output/number_%03d.pdf
pdftk numbering.pdf burst output pdf_numbering_output/number_%03d.pdf
pdftk textbook_full_original.pdf burst output pdf_numbering_output/page_%03d.pdf
for i in $(seq -f %03g 1 $num_pages) ; do pdftk pdf_numbering_output/page_$i.pdf background pdf_numbering_output/number_$i.pdf output pdf_numbering_output/new_$i.pdf; done
pdftk pdf_numbering_output/new_???.pdf output textbook_full.pdf
sed -i "s/$num_pages/194/" pdf-generation/numbering.tex
- name: Remove temporary files, make temporary copy to upload as artifact
run: |
rm -rf pdf_output
rm -rf pdf_numbering_output
cp textbook_full.pdf textbook_full_cpy.pdf
sed -i "s/$num_pages/161/" pdf-generation/numbering.tex
- name: Upload PDF as an artifact
uses: actions/upload-artifact@v4
with:
name: textbook-full-copy
path: textbook_full_cpy.pdf

- name: Remove temporary files
run: |
rm -rf pdf_output
rm -rf pdf_numbering_output
rm -rf textbook_full_original.pdf
rm -rf textbook_full_cpy.pdf
- name: Commit changes to a new branch
if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Update PDF of textbook')
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ $RECYCLE.BIN/

# PDF Page Numbering
pdf-generation/numbering.aux
numbering.aux
numbering.pdf
textbook_full_cpy.pdf
textbook_full_original.pdf
pdf-generation/numbering.fdb_latexmk
pdf-generation/numbering.fls
pdf-generation/numbering.log
Expand Down
Binary file modified pdf-generation/numbering.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pdf-generation/numbering.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
\usepackage{multido}
\usepackage[hmargin=.8cm,vmargin=1.5cm,nohead,nofoot]{geometry}
\begin{document}
\multido{}{194}{\vphantom{x}\newpage}
\multido{}{161}{\vphantom{x}\newpage}
\end{document}

0 comments on commit 539f457

Please sign in to comment.