Skip to content

Commit 18b6e24

Browse files
committed
Fix PDF generation
Subresources were not downloading correctly, likely due to the old version of Prince having out-of-date SSL support. (I noticed it emitting warnings about invalid certificates for resources.whatwg.org.) This upgrades to the latest version of Prince. Doing so requires abandoning pdfsizeopt, as pdfsizeopt is not compatible with modern Prince. Oh well. This allows us to use a .deb-based installation procedure for Prince instead of compiling from source, which is nice. In particular we no longer need to manually install dependencies.
1 parent 4c63f27 commit 18b6e24

File tree

2 files changed

+7
-26
lines changed

2 files changed

+7
-26
lines changed

ci-build/Dockerfile

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,31 @@ FROM debian:stable
55
RUN apt-get update && \
66
apt-get install --yes --no-install-recommends \
77
ca-certificates curl rsync git \
8-
libfontconfig1 libgomp1 libxml2 \
98
default-jre \
109
python3 python3-pip \
1110
fonts-dejavu fonts-droid-fallback fonts-liberation fonts-symbola fonts-unfonts-core
1211

1312
# Dependency lines above are:
1413
# - General
15-
# - Prince
1614
# - validator
1715
# - Highlighter
1816
# - fonts, for when Prince renders to PDF
1917

2018
COPY --from=whatwg/wattsi:latest /whatwg/wattsi/bin/wattsi /bin/wattsi
21-
COPY --from=ptspts/pdfsizeopt:latest /bin /bin/pdfsizeopt
2219
RUN pip3 install bs-highlighter
2320

24-
# The DockerHub container for pdfsizeopt has some useful auxiliary binaries it depends on, but the
25-
# main binary is outdated and needs updating directly from GitHub:
26-
# TODO: consolidate these two lines when https://github.com/moby/buildkit/pull/1492 gets released
27-
# (see https://github.com/moby/moby/issues/34819).
28-
ADD https://github.com/pts/pdfsizeopt/blob/master/pdfsizeopt.single?raw=true /bin/pdfsizeopt/pdfsizeopt
29-
RUN chmod a+rwx /bin/pdfsizeopt/pdfsizeopt
30-
3121
# The DockerHub container for the validator only contains the server version, so we get the .jar
3222
# from GitHub:
3323
ADD https://github.com/validator/validator/releases/download/latest/vnu.jar /whatwg/
3424

3525
# Trying to copy Prince from its DockerHub container like the others does not work; it has too many
36-
# shared library dependencies. Additionally, Prince 12 and 13 have bad interactions with pdfsizeopt
37-
# (https://github.com/pts/pdfsizeopt/issues/145, https://github.com/whatwg/html-build/issues/255),
38-
# and Prince 11's .deb file only works with older version of Debian. So, we do it this way (plus the
39-
# manual dependency installations in the apt-get section above).
40-
ADD https://www.princexml.com/download/prince-11.3-linux-generic-x86_64.tar.gz /whatwg/prince.tar.gz
26+
# shared library dependencies. Probably this is a job for Docker Compose... we should learn how that
27+
# works one day.
28+
ADD https://www.princexml.com/download/prince_14.2-1_debian10_amd64.deb /whatwg/prince.deb
4129
RUN cd /whatwg && \
42-
tar xzf prince.tar.gz && \
43-
echo /whatwg/prince | /whatwg/prince-11.3-linux-generic-x86_64/install.sh && \
44-
echo '@font-face { font-family: serif; src: local("Symbola") }' >> /whatwg/prince/lib/prince/style/fonts.css && \
45-
rm -rf /whatwg/prince.tar.gz /whatwg/prince-11.3-linux-generic-x86_64
30+
apt-get install --yes ./prince.deb && \
31+
echo '@font-face { font-family: serif; src: local("Symbola") }' >> /usr/lib/prince/style/fonts.css && \
32+
rm -rf /whatwg/prince.deb
4633

4734
ADD . /whatwg/html-build
4835

ci-build/inside-container.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,4 @@ echo ""
2424

2525
echo ""
2626
echo "Building PDF..."
27-
PDF_TMP="$(mktemp --suffix=.pdf)"
28-
PATH=/whatwg/prince/bin:$PATH prince --verbose --output "$PDF_TMP" "http://0.0.0.0:$PDF_SERVE_PORT/"
29-
30-
echo ""
31-
echo "Optimizing PDF..."
32-
TMP_DIR=$(mktemp -d)
33-
PATH=/bin/pdfsizeopt:$PATH pdfsizeopt --v=30 "--tmp-dir=$TMP_DIR" "$PDF_TMP" "$HTML_OUTPUT/print.pdf"
27+
PATH=/whatwg/prince/bin:$PATH prince --verbose --output "$HTML_OUTPUT/print.pdf" "http://0.0.0.0:$PDF_SERVE_PORT/"

0 commit comments

Comments
 (0)