PDFDispatch Docs

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

FieldTypeDefaultWhat it does
files requiredfile(s)–One or more documents. Each becomes one PDF; several come back as a ZIP unless merge=true.
mergebooleanfalseJoin all the PDFs into one, in the order of the file names.
passwordstring–The password that opens a protected document.
landscapebooleanfalseLandscape pages, where the document does not set its own orientation.
nativePageRangesstring–Only these pages, for example 1-4 or 1,3,5-7.
singlePageSheetsbooleanfalseSpreadsheets: each sheet on one page, however big.
exportFormFieldsbooleantrueKeep form fields fillable. false prints their content as plain text.
allowDuplicateFieldNamesbooleanfalseAllow several form fields with the same name.
exportBookmarksbooleantrueTurn the document’s headings into PDF bookmarks.
exportBookmarksToPdfDestinationbooleanfalseAlso make named destinations from the bookmarks, so links like file.pdf#Chapter2 work.
openBookmarkLevelsinteger-1How many bookmark levels a viewer opens at first, 1 to 10; -1 for all.
updateIndexesbooleantrueRefresh the table of contents and other indexes before converting.
exportNotes, exportNotesInMarginbooleanfalseInclude comments, as PDF notes or in the page margin.
exportNotesPages, exportOnlyNotesPagesbooleanfalsePresentations, add the speaker notes pages, or print only those.
exportHiddenSlidesbooleanfalsePresentations, include hidden slides.
exportPlaceholdersbooleanfalseShow the marks of empty placeholder fields.
skipEmptyPagesbooleanfalseLeave out pages that are empty only because of automatic page breaks.
addOriginalDocumentAsStreambooleanfalsePut a copy of the source document inside the PDF.
convertOooTargetToPdfTarget, exportLinksRelativeFsysbooleanfalseLinks between documents: point them at the .pdf instead of the source, or keep them relative to the file system.
qualityinteger90JPEG quality of the images, 1 to 100.
losslessImageCompressionbooleanfalseKeep images lossless instead of JPEG (bigger files).
reduceImageResolution, maxImageResolutionboolean, integerfalse, 300Scale images down to at most this many DPI: 75, 150, 300, 600 or 1200.
nativeWatermarkText, nativeTiledWatermarkTextstring–A text watermark the converter draws on every page, once or repeated over the page.
nativeWatermarkColor, nativeWatermarkFontHeight, nativeWatermarkRotateAngle, nativeWatermarkFontNameinteger, integer, integer, string8388223, 0, 0, HelveticaIts 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.
generateTaggedPdfbooleanfalseAdd structure tags for screen readers.
nativePdfFormatsbooleantrueWrite pdfa/pdfua during the conversion itself (better results). It falls back to a second pass when other post-processing is asked for.
flattenbooleanfalseFlatten form fields and annotations into the page.
initialView, initialPage, magnification, zoom, pageLayoutintegers0, 1, 0, 100, 0How 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, useTransitionEffectsbooleanfalse (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:

KindExtensions
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 right password, or nativePageRanges that do not fit. The message names the file.
  • 500 with “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 the X-Request-Id.
  • 503 after 60 seconds: the document takes too long. Split it, or remove large embedded media.