Create pdfs from HTML documents, including seperate headers and footers.
2.0K
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y --no-install-recommends npm wget fontconfig \
libfontconfig1 libfreetype6 libjpeg-turbo8 libx11-6 libxext6 \
libxrender1 xfonts-base xfonts-75dpi curl python-software-properties && \
wget -q http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb && \
dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb && \
rm /usr/local/bin/wkhtmltoimage && \
curl -sL https://deb.nodesource.com/setup_7.x | bash - && \
apt-get install -y nodejs
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt-get install -y msttcorefonts
COPY package.json /
RUN npm install
COPY server.js /
COPY .babelrc /
EXPOSE 5555
RUN node --version && \
npm --version
CMD ["npm", "start"]
Here content, header, and footer are complete HTML docs encoded in base64.
const body = JSON.stringify({
content,
header,
footer,
options: {
'margin-left': '0',
'margin-right': '0',
'margin-top': '70',
'header-spacing': '5',
'page-size': 'Letter',
},
});
fetch('http://localhost:5555', {
method: 'POST',
headers: {
Connection: 'keep-alive',
'content-type': 'application/json',
},
body,
})
.then(data => data.buffer())
Content type
Image
Digest
Size
88.8 MB
Last updated
over 5 years ago
docker pull peloton/html2pdf