Office documents
Word, Excel, PowerPoint, OpenDocument and about a hundred other formats, converted by LibreOffice. One file in, one PDF out; several files give a ZIP, or one PDF with merge=true.
POST https://api.pdfdispatch.com/v1/convert/office
Form fields
| Field | Type | Default | What it does |
|---|---|---|---|
files required | file(s) | – | One or more documents. Each becomes one PDF; several come back as a ZIP unless merge=true. |
merge | boolean | false | Join all the PDFs into one, in the order of the file names. |
password | string | – | The password that opens a protected document. |
landscape | boolean | false | Landscape pages, where the document does not set its own orientation. |
nativePageRanges | string | – | Only these pages, for example 1-4 or 1,3,5-7. |
singlePageSheets | boolean | false | Spreadsheets: each sheet on one page, however big. |
exportFormFields | boolean | true | Keep form fields fillable. false prints their content as plain text. |
allowDuplicateFieldNames | boolean | false | Allow several form fields with the same name. |
exportBookmarks | boolean | true | Turn the document’s headings into PDF bookmarks. |
exportBookmarksToPdfDestination | boolean | false | Also make named destinations from the bookmarks, so links like file.pdf#Chapter2 work. |
openBookmarkLevels | integer | -1 | How many bookmark levels a viewer opens at first, 1 to 10; -1 for all. |
updateIndexes | boolean | true | Refresh the table of contents and other indexes before converting. |
exportNotes, exportNotesInMargin | boolean | false | Include comments, as PDF notes or in the page margin. |
exportNotesPages, exportOnlyNotesPages | boolean | false | Presentations, add the speaker notes pages, or print only those. |
exportHiddenSlides | boolean | false | Presentations, include hidden slides. |
exportPlaceholders | boolean | false | Show the marks of empty placeholder fields. |
skipEmptyPages | boolean | false | Leave out pages that are empty only because of automatic page breaks. |
addOriginalDocumentAsStream | boolean | false | Put a copy of the source document inside the PDF. |
convertOooTargetToPdfTarget, exportLinksRelativeFsys | boolean | false | Links between documents: point them at the .pdf instead of the source, or keep them relative to the file system. |
quality | integer | 90 | JPEG quality of the images, 1 to 100. |
losslessImageCompression | boolean | false | Keep images lossless instead of JPEG (bigger files). |
reduceImageResolution, maxImageResolution | boolean, integer | false, 300 | Scale images down to at most this many DPI: 75, 150, 300, 600 or 1200. |
nativeWatermarkText, nativeTiledWatermarkText | string | – | A text watermark the converter draws on every page, once or repeated over the page. |
nativeWatermarkColor, nativeWatermarkFontHeight, nativeWatermarkRotateAngle, nativeWatermarkFontName | integer, integer, integer, string | 8388223, 0, 0, Helvetica | Its colour as a decimal RGB number (16711680 is red), font size (0: fit the page), angle in tenths of a degree (450 is 45°) and font. |
generateTaggedPdf | boolean | false | Add structure tags for screen readers. |
nativePdfFormats | boolean | true | Write pdfa/pdfua during the conversion itself (better results). It falls back to a second pass when other post-processing is asked for. |
flatten | boolean | false | Flatten form fields and annotations into the page. |
initialView, initialPage, magnification, zoom, pageLayout | integers | 0, 1, 0, 100, 0 | How a viewer first shows the PDF. initialView: 0 page only, 1 with bookmarks, 2 with thumbnails. magnification: 0 default, 1 whole page, 2 page width, 3 visible width, 4 the zoom percentage. pageLayout: 0 default, 1 single page, 2 continuous, 3 two pages side by side. |
firstPageOnLeft, resizeWindowToInitialPage, centerWindow, openInFullScreenMode, displayPDFDocumentTitle, hideViewerMenubar, hideViewerToolbar, hideViewerWindowControls, useTransitionEffects | boolean | false (title and transitions: true) | Further viewer hints. Viewers may ignore them. |
The options on conversion routes apply as well: PDF/A and PDF/UA, metadata, passwords, watermarks, rotation, splitting, compression, attachments and Factur-X. Headers are as for HTML.
File types
The extension of each file decides how it is read, so it must be right (a .doc that is really a .docx may fail).
The most common:
| Kind | Extensions |
|---|---|
| Text | .docx .doc .docm .dotx .odt .ott .fodt .rtf .txt .wpd .wps .pages .abw .lwp .hwp |
| Spreadsheets | .xlsx .xls .xlsm .xlsb .xltx .ods .ots .fods .csv .numbers .dbf .wk1 |
| Presentations | .pptx .ppt .pptm .ppsx .pps .potx .odp .otp .fodp .key |
| Drawings and images | .odg .vsdx .vsd .svg .png .jpg .gif .tif .bmp .emf .wmf .eps .psd .cdr .pub |
| Other | .html .xhtml .xml .epub .pdf (re-exported) and older StarOffice and Works formats |
For HTML, prefer the HTML route: it handles modern CSS and JavaScript, this route does not.
Examples
One document:
curl --fail-with-body \
--header "Authorization: Bearer $PDD_KEY" \
--form files=@offer.docx \
--output offer.pdf \
https://api.pdfdispatch.com/v1/convert/office
A workbook with each sheet on a single page, as PDF/A for the archive:
curl --fail-with-body \
--header "Authorization: Bearer $PDD_KEY" \
--form files=@q3-figures.xlsx \
--form singlePageSheets=true \
--form pdfa=PDF/A-2b \
--output q3-figures.pdf \
https://api.pdfdispatch.com/v1/convert/office
Three documents joined into one PDF (in the order of their names):
curl --fail-with-body \
--header "Authorization: Bearer $PDD_KEY" \
--form files=@1-cover.docx \
--form files=@2-terms.odt \
--form files=@3-prices.xlsx \
--form merge=true \
--output offer.pdf \
https://api.pdfdispatch.com/v1/convert/office
In Node.js:
import { openAsBlob } from "node:fs";
import { writeFile } from "node:fs/promises";
const form = new FormData();
form.append("files", await openAsBlob("offer.docx"), "offer.docx");
const res = await fetch("https://api.pdfdispatch.com/v1/convert/office", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.PDD_KEY}` },
body: form,
});
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
await writeFile("offer.pdf", Buffer.from(await res.arrayBuffer()));
Fonts and layout
The converter uses the fonts it has. When a document asks for one it does not have (some Microsoft fonts, a corporate font), a similar font takes its place, and line and page breaks can move. To keep the exact look, embed the fonts in the document when you save it (Word: Options, Save, “Embed fonts in the file”; LibreOffice: File, Properties, Font).
Common fonts with free equivalents (Arial, Times New Roman, Courier New, Calibri, Cambria) keep their metrics, so the layout usually holds.
When it fails
400: the file could not be read (damaged, or an extension that does not match its content), a protected document without the rightpassword, ornativePageRangesthat do not fit. The message names the file.500with “LibreOffice failed to convert the document”: the request was valid but the conversion broke, usually on a very large or unusual document. This one is worth a retry; if it fails again, write to us with theX-Request-Id.503after 60 seconds: the document takes too long. Split it, or remove large embedded media.