Start handbook build process

This commit is contained in:
Matt McWilliams 2022-08-29 16:20:29 -04:00
parent d54277ede8
commit 31fd9ae459
3 changed files with 59 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
handbook

35
compile_handbook.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/bash
mkdir -p handbook
TMP_HTML="$(realpath ./handbook/index.html)"
HTML="html/index.html"
LAYOUT_PDF="pdf/handbook.pdf"
BODY_VAR="{{BODY_HTML}}"
TMPL_HTML=`cat tmpl/layout.html.tmpl`
BODY_CONTENT=`cat "${HTML}"`
ALL_HTML="${TMPL_HTML/$BODY_VAR/$BODY_CONTENT}"
echo "${ALL_HTML}" > "${TMP_HTML}"
chromium-browser \
--headless \
--no-sandbox \
--disable-gpu \
--run-all-compositor-stages-before-draw \
--print-to-pdf-no-header \
--no-margins \
--print-to-pdf="${LAYOUT_PDF}" \
"${TMP_HTML}"
mkdir -p handbook
cd handbook
#convert -density 600 "../${LAYOUT_PDF}" -quality 90 page-%3d.jpg
pdftoppm "../${LAYOUT_PDF}" page -jpeg -rx 600 -ry 600
cd ..
rm -f "${TMP_HTML}"
rm -f "${LAYOUT_PDF}"

23
tmpl/layout.html.tmpl Normal file
View File

@ -0,0 +1,23 @@
<!doctype html>
<html>
<head>
<title></title>
<style>
@media print {
@page { padding: 0.5cm 0.5cm 1cm 0.5cm; }
body {
font-size: 32px;
font-family: monospace;
}
pre{
size: 18.45cm 21cm;
margin: 0;
background: rgb(225, 225, 225);
}
}
</style>
</head>
<body>
{{BODY_HTML}}
</body>
</html>