Document creation API
Overview
Apryse's document creation framework (the FlowDocument API) lets you generate PDFs without positioning anything on a page. Create a strong foundation for end-to-end PDF creation workflows.
You can:
You build a content tree with paragraphs, tables, lists, shapes, charts and floats.
You style the elements with familiar word-processor concepts like fonts, colors, indents, justification, borders, tab stops.
Apryse SDK paginates the tree into a PDF, breaking content across pages, flowing text around floats, and resolving page numbers.
Sections let you mix page sizes, orientations, headers and footers within a single document.
It's self-contained, with no external dependencies and no office application required.
This is complementary to template based generation. Use templates when a designer owns the layout in an Office file, and use the document creation API when the document structure itself is computed by your application.
Use cases include:
Invoice generation at volume: company branding, line-item tables, page numbers, payment information, metadata, and configured page size and margins.
Analytics and business reports: structured content, charts or chart-like visual elements, branded headers, landscape pages, and custom page numbering.
Contracts and proposals: logos, hyperlinks to terms or support, disclaimers in footers, shapes used as signature placeholders, metadata, and multi-page layout.
Statements, dashboards, labels, and other dynamically generated documents produced from operational systems, CRMs, ERPs, billing systems, and reporting tools.
OEM teams embedding the SDK in their own product and needing programmatic PDF generation as part of it.
Hello world

That is the whole workflow: create a FlowDocument, append content, call PaginateToPDF, and save the resulting PDFDoc.
Because the result is an ordinary PDFDoc, the rest of the SDK applies to it as usual. You can encrypt it, append other documents, or set its document metadata before saving.
Flow layout vs. fixed layout
The ElementBuilder / ElementWriter API is a fixed layout API. You decide the exact coordinates of every glyph, line and image. The document creation API is a flow layout API:
Fixed layout (ElementBuilder)
Flow layout (FlowDocument)
You specify
Absolute positions
Logical structure
Pagination
Manual
Automatic
Text wrapping
Manual
Automatic
Page numbers
Computed by you
Dynamic elements
Best for
Precise stamping, overlays
Reports, invoices, letters, newsletters
The content tree
Everything you add to a document is a ContentElement. Elements that can contain other elements are ContentNodes, and the subset of nodes that accept paragraphs, tables and lists are ContentContainers.
Key relationships to remember:
A
FlowDocumentis itself aContentContainer. Content added directly to it goes into the current section.A
TableCellis a fullContentContainer, so cells can hold paragraphs, nested tables, and lists.A
Shapeexposes aContentContainerthroughGetTextBox, which turns any shape into a text box.A
Floatis aContentContainerthat is lifted out of the main flow.
Styling
Two styling surfaces exist:
TextStyledElement: Character level styling (font face, size, bold, italic, text color, background color). Retrieved withGetTextStyledElementfrom any content element. Setting it on a node applies the style to the content added to that node.Element specific setters: Paragraph indents, spacing and justification, cell borders and alignment, shape geometry and fill, among others.
Conventions
All dimensions are in points (1/72 inch). US Letter is
612 x 792, A4 is595 x 842.Colors are 8-bit RGB triplets in the range
[0..255].Fonts are resolved by name through the platform font providers. Prefer widely available families, or ship the fonts you need, so the output is identical across machines.
Build, then paginate.
PaginateToPDFis the only expensive step; calling it more than once for the same document repeats the whole layout.Generated PDFs carry structure tags, so the output is accessible by construction.
Enum spelling differs per language. C++ and Python use
Paragraph.e_text_justify_center, C# usesParagraph.TextJustification.e_center, Java and JavaScript useParagraph.TextJustification.e_text_justify_center, Go usesParagraphE_text_justify_center, PHP usesParagraph::e_text_justify_center, Ruby usesParagraph::E_text_justify_center, and Objective-C usese_ptpara_text_justify_center.Every JavaScript call is asynchronous. The Node.js and WebViewer bindings return promises, so each call has to be awaited, including the property getters such as
getTextStyledElement.Objective-C renames overloads.
AddParagraph(text)becomesAddParagraphWithText:,AddImage(w, h, path)becomesAddImageWithPath:height:image_path:, andSetNumberFormat(format, suffix, cascade)becomesSetNumberFormatWithSuffix:suffix:cascade:.
Document creation options
There are several options available to use when programmatically creating a document.
Text runs, character styling, justification, indents, tab stops, hyperlinks.
Ordered lists, nesting, number formats, label styling.
Rows and cells, borders, shading, alignment, cell merging, nested content.
Inline images, shape types, text boxes, rotation and flipping.
Positioning content outside the flow and wrapping text around it.
Page setup per section, headers and footers, dynamic page numbers.
Adding charts and sizing them.
Full specification of the chart definition string.
Inspecting and post-processing content before pagination.
Setting the title, author, subject, and keywords of the generated PDF.
Further Reading
Template generation for generating documents from Office templates and JSON data instead.
Last updated
Was this helpful?