SaveDOCXToStream
Document conversion, extraction, DOCX, streams
Description
Converts a PDF page range into an editable WordprocessingML document and writes the DOCX package at the current stream position
Syntax
Function TPDFlib.SaveDOCXToStream(Const PageRange: WideString;
Options: Integer; Target: TStream): Integer;Parameters
| PageRange | A one-based page range, or an empty string for every page; explicit page order is preserved |
|---|---|
| Options | A bit mask: PDF_DOCX_INCLUDE_IMAGES = 1 embeds page images as floating PNG objects, PDF_DOCX_DETECT_HEADINGS = 2 maps large short lines to Heading 1 through Heading 3, PDF_DOCX_PRESERVE_STYLES = 4 retains font names, sizes, colours, bold, italic, superscript and subscript, and PDF_DOCX_PRESERVE_PAGE_BREAKS = 8 inserts editable page breaks; PDF_DOCX_DEFAULT enables all four |
| Target | The destination stream, which does not become owned by the library |
Return values
Returns the number of converted pages, or zero when validation, cancellation, extraction, packaging, or writing fails
Remarks
Reading-order paragraphs, bullet and numbered lists, and detected tables become native editable Word content rather than page snapshots
Image data is compressed into the package as each page is processed, so image memory follows the current page; the compact document XML body remains buffered until the ZIP central directory is written
The output is a deterministic DOCX ZIP package with CRC-checked raw Deflate entries and requires no Office installation
The selected PDF page is restored before the call returns
LastErrorCode is 114 for invalid arguments and 518 for extraction, packaging, or stream failures
See also
SaveDOCXToFile, ExtractStructuredDocument, ExportDocumentHTML