Combine a Word document and a web page
You have a cover page as HTML and a report as a Word document. You want one PDF: the cover printed by Chromium, then the report.
Requests
Convert the Word document first:
curl \
--request POST http://localhost:3000/forms/libreoffice/convert \
--form files=@report.docx \
-o report.pdf
Then print the cover, and insert the report after its page:
curl \
--request POST http://localhost:3000/forms/chromium/convert/html \
--form files=@index.html \
--form files=@style.css \
--form files=@report.pdf \
--form 'stages=[
{ "op": "insert", "source": "report.pdf", "at": 1 }
]' \
-o combined.pdf
Result
A four-page PDF: the cover, then the report's three pages.
How it works
- Each engine makes its own part: Chromium the web page, LibreOffice the document.
- A conversion's stages see only the PDF it prints.
insertbrings in the uploadedreport.pdfby name: see Insert pages. at: 1inserts after the first page.at: 0puts the report before the cover.
Variations
- Several documents: convert them in one request with a
mergestage, then insert the result. - The cover on each page instead:
stamp-pdfdraws one PDF's page over another's. - One request only: the LibreOffice route converts
.htmltoo, but LibreOffice then lays the page out, not Chromium.