Skip to main content
Version: 9.x

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. insert brings in the uploaded report.pdf by name: see Insert pages.
  • at: 1 inserts after the first page. at: 0 puts the report before the cover.

Variations​

  • Several documents: convert them in one request with a merge stage, then insert the result.
  • The cover on each page instead: stamp-pdf draws one PDF's page over another's.
  • One request only: the LibreOffice route converts .html too, but LibreOffice then lays the page out, not Chromium.