Generate wrapper files
This commit is contained in:
parent
1b0d5db395
commit
7850dbd432
|
@ -1,8 +1,9 @@
|
|||
build
|
||||
pdf
|
||||
|
||||
# TODO: fix
|
||||
|
||||
# tex/**/*
|
||||
# !tex/**/*.tex
|
||||
# !tex/**/*.tex
|
||||
# venv
|
||||
bin
|
||||
lib
|
||||
lib64
|
||||
pyvenv.cfg
|
||||
include
|
42
Makefile
42
Makefile
|
@ -1,24 +1,40 @@
|
|||
.PHONY: clean all
|
||||
|
||||
build:
|
||||
all: wrapper-main.pdf wrapper-nx.pdf
|
||||
|
||||
clean:
|
||||
rm -r build pdf
|
||||
|
||||
dirs:
|
||||
mkdir build
|
||||
mkdir build/texdata
|
||||
|
||||
pdf:
|
||||
mkdir pdf
|
||||
|
||||
build/nx.tex: build
|
||||
python python/toTex.py
|
||||
build/texdata/nx.tex: dirs
|
||||
python python/htmlToTex.py
|
||||
|
||||
build/nx.tex: build/texdata/nx.tex
|
||||
python python/createMainDoc.py
|
||||
|
||||
tex/nx.tex: build/nx.tex
|
||||
python python/createDoc.py
|
||||
|
||||
main.pdf: tex/nx.tex pdf
|
||||
main.pdf: build/nx.tex
|
||||
cd build; xelatex main.tex
|
||||
mv build/*.pdf pdf
|
||||
|
||||
nx.pdf: tex/nx.tex pdf
|
||||
nx.pdf: build/nx.tex
|
||||
cd build; for n in 5 4 3 2 1; do \
|
||||
xelatex ../tex/$$n.tex; \
|
||||
xelatex n$$n.tex; \
|
||||
done
|
||||
mv build/*.pdf pdf
|
||||
|
||||
wrapper-main.pdf: main.pdf
|
||||
python python/createWrapperDoc.py main.pdf main-wrapper.tex
|
||||
cd build; pdflatex main-wrapper.tex
|
||||
mv build/main-wrapper.pdf pdf/main.pdf
|
||||
|
||||
wrapper-nx.pdf: nx.pdf
|
||||
for n in 5 4 3 2 1; do \
|
||||
python python/createWrapperDoc.py n$$n.pdf n$$n-wrapper.tex; \
|
||||
done;
|
||||
|
||||
cd build; for n in 5 4 3 2 1; do \
|
||||
pdflatex n$$n-wrapper.tex; \
|
||||
mv n$$n-wrapper.pdf ../pdf/n$$n.pdf; \
|
||||
done;
|
|
@ -0,0 +1,26 @@
|
|||
from sys import argv
|
||||
|
||||
from PyPDF2 import PdfFileReader
|
||||
|
||||
def inject_into_template(
|
||||
output_file,
|
||||
string,
|
||||
template='tex/doc.tex.template',
|
||||
replacement_char='###'
|
||||
):
|
||||
with open(template) as file:
|
||||
content = file.read().replace(replacement_char, string)
|
||||
|
||||
with open(output_file, 'w') as file:
|
||||
file.write(content)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pdfPath, outputPath = argv[1:3]
|
||||
pdf = PdfFileReader(open(f'build/{pdfPath}','rb'))
|
||||
pageNum = pdf.getNumPages()
|
||||
|
||||
inject_into_template(
|
||||
f'build/{outputPath}',
|
||||
f'\\includepdf[pages=-,nup=1x2,signature={pageNum},landscape,booklet=true]{{{pdfPath}}}',
|
||||
template="tex/wrapper.tex.template"
|
||||
)
|
|
@ -0,0 +1,2 @@
|
|||
lxml==4.7.1
|
||||
PyPDF2==1.26.0
|
|
@ -14,7 +14,7 @@
|
|||
Data made by Jonathan Waller at \url{#1} \\
|
||||
\vspace*{15mm}
|
||||
Project at \\
|
||||
{ \Huge \faicon{github-square} } \url{https://github.com/h7x4abk3g}
|
||||
{ \Huge \faicon{github-square} } \url{https://github.com/h7x4ABk3g/tanos-japanese-word-books/}
|
||||
}
|
||||
|
||||
\newcommand{\fullFrontpage}{
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
\documentclass[a4paper, twoside]{article}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{pdfpages}
|
||||
\begin{document}
|
||||
###
|
||||
\end{document}
|
Loading…
Reference in New Issue