PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
ComPDF Conversion SDK supports converting Word documents to PDF files. During conversion you can choose to generate PDF bookmarks, output only specific pages. This function is provided by Conversion::wordToPdf. Its options are set through ConvertOption, the same structure used for PDF conversion; only wordPdfBookmarkMode and pageRanges take effect for Word to PDF, and the other members are ignored.
Conversion::wordToPdf(string $in, string $out, ?ConvertOption $opt = null, ?ConvertCallback $cb = null): int
Word to PDF uses only the following members of ConvertOption:
| Field | Type | Default | Description |
|---|---|---|---|
wordPdfBookmarkMode | WordPdfBookmarkMode | WordPdfBookmarkMode::NONE | How PDF bookmarks (the outline shown in a reader's navigation panel) are generated |
pageRanges | string | empty | Pages to output, e.g. "1-3,5,7-9"; empty outputs every page |
Values of WordPdfBookmarkMode:
| Value | Description |
|---|---|
WordPdfBookmarkMode::NONE | Do not generate bookmarks |
WordPdfBookmarkMode::HEADINGS | One bookmark per heading (a paragraph with an outline level), nested by level |
WordPdfBookmarkMode::WORD_BOOKMARKS | One bookmark per Word bookmark, named after it |
UNSUPPORTED_FEATURE (95). The PDF is usually still produced; check the output file.$options = new \Conversion\ConvertOption();
$options->wordPdfBookmarkMode = \Conversion\WordPdfBookmarkMode::HEADINGS;
$options->pageRanges = "1-3,5,7-9";
$result = \Conversion\Conversion::wordToPdf("input.docx", "output.pdf", $options);