Portable print plans
Separate logical pagination from native output: lxPortablePrint creates an immutable print plan from a detached render snapshot, and lxPortableCairo draws its pages as PDF, SVG or PNG on Linux and macOS
The planner uses physical points and complete cell boundaries, preserves merged ranges, repeats row and column titles, and applies disjoint print areas, manual breaks, orientation, margins, centering, scaling and page order without changing the source workbook
Use workbook page setup
CreateXLSPortableWorkbookPrintPlan in lxPortableWorkbookPrint has overloads for a borrowed TXLSWorkbook and TXLSXWorkbook; both accept SheetIndex, OriginRow, OriginColumn, Snapshot and Defaults
The sheet index and snapshot origin are one-based; the adapter requires a snapshot from the current workbook generation and a captured rectangle containing every complete print area and repeated title range
Snapshot identity includes its generation, while the caller supplies the matching sheet and origin; retain the correct sheet context when transporting a snapshot because the snapshot format does not encode a workbook or worksheet identity
Snapshot := CaptureXLSPortableRenderSnapshot(Owner, 1, 1, 1, 30, 6,
XLSDefaultPortableRenderLimits, Geometry);
Plan := CreateXLSPortableWorkbookPrintPlan(Workbook, 1, 1, 1,
Snapshot, XLSDefaultPortablePrintOptions);
Layout := PrepareXLSPortableCairoLayout(Plan, Fonts,
XLSDefaultPortableCairoOptions);
try
Files := Layout.Save('/srv/output/report.pdf', xpcfPDF);
Files := Layout.Save('/srv/output/report.svg', xpcfSVG);
Files := Layout.Save('/srv/output/report.png', xpcfPNG);
finally
Layout.Free;
end;
Use the explicit font-backed geometry provider described in direct native workbook capture when capturing on Linux or macOS; pagination itself does not require Cairo, font files, Excel or a printer driver
The workbook adapter takes a temporary read lease, reads existing metadata and returns detached data; it neither adopts a raw workbook through an owning interface nor retains a workbook lease in the result
Quoted sheet names, escaped quotes and comma-separated print areas are accepted only for the selected worksheet; references outside the captured rectangle, foreign sheet references, incomplete title ranges and malformed ranges reject explicitly
Recognized paper sizes are Letter, Tabloid, Ledger, Legal, A3, A4, A5, B4 and B5; an unspecified paper size uses Defaults.PageWidthPoints and Defaults.PageHeightPoints, while an unrecognized explicit paper size rejects
Header and footer content, printed row/column headings, enabled print gridlines, black-and-white or draft appearance, comment printing and error substitutions currently reject because this adapter cannot draw those settings faithfully; Classic workbooks enable print gridlines by default, so disable PageSetup.PrintGridlines for this supported contract
Scaling mode and native defaults
TXLSXWorksheet.PageFitToPages selects fit mode independently of its dimensions: setting FitToWidth or FitToHeight selects fit mode, and setting PageScale selects percentage scaling
XLSX import preserves sheetPr/pageSetUpPr/@fitToPage and the OOXML default of one for an omitted fit dimension; export retains explicit zero dimensions, and XLS/XLSX conversion preserves the selected mode
Percentage scaling ignores stale fit dimensions; fit mode ignores a stored percentage scale, and positive fit dimensions ignore manual breaks; zero on both axes retains manual breaks at 100% scale, while positive limits reduce oversized content without enlarging a small range
Logical pagination depends on the supplied snapshot geometry; printer-driver metrics and Excel PDF export scaling can change physical output and are not an exact visual equivalence guarantee
Build a detached plan directly
CreateXLSPortablePrintPlan(Snapshot, Areas, Options) accepts zero-based inclusive TXLSPortablePrintRanges; an empty Areas array selects the whole snapshot, and each TXLSPortablePrintRange contains FirstRow, FirstColumn, LastRow and LastColumn
Start with XLSDefaultPortablePrintOptions, then set the fields of TXLSPortablePrintOptions below
| Fields | Contract |
|---|---|
PageWidthPoints, PageHeightPoints | Positive physical paper dimensions in points, default A4 |
MarginLeftPoints, MarginTopPoints, MarginRightPoints, MarginBottomPoints | Nonnegative margins leaving a positive printable rectangle, default 36 points |
Landscape, CenterHorizontally, CenterVertically | Landscape swaps portrait dimensions; centering applies to each page body and its repeated titles |
ScalePercent | 10 through 400, default 100; applies when neither fit dimension is positive |
FitToPagesWide, FitToPagesTall | Nonnegative page limits, zero for an unrestricted axis; positive limits find a feasible scale between 10% and 100% |
TitleFirstRow, TitleLastRow, TitleFirstColumn, TitleLastColumn | Complete zero-based inclusive title ranges, or -1 on both endpoints to disable that axis |
RowBreaks, ColumnBreaks | TXLSPortablePrintBreaks arrays of strictly ascending unique zero-based positions where a new page begins; workbook adaptation sorts detached metadata without editing the sheet |
Order | TXLSPortablePrintOrder: xppoDownThenOver or xppoOverThenDown |
MaxPages | Positive total page limit, default 256 and maximum 100,000 |
MaxPlanBytes | Working storage, detached snapshot payload and page records share this positive memory budget, default 64 MiB and maximum 1 GiB |
MaxPlanningSteps | Positive bounded planning work budget, default 64 Mi steps and maximum 2 Gi steps; exceeding it raises EXLSPortablePrintBudget |
Geometry must be finite; hidden dimensions have zero size, a page break may not split a merge, an area or title may not partially intersect a merge, and an oversized cell or merge rejects instead of being silently cut
Inspect or render the result
IXLSPortablePrintPlan.Snapshot owns a detached immutable render snapshot, PageCount reports the logical page count, and zero-based Pages[Index] returns a TXLSPortablePrintPage with a detached tile array
Each page exposes AreaIndex, AcrossIndex, DownIndex, its zero-based inclusive Body, Scale, PageWidthPoints, PageHeightPoints and Tiles
TXLSPortablePrintTiles contains at most four TXLSPortablePrintTile records for the repeated corner, title rows, title columns and body; each tile exposes unscaled source SourceLeft, SourceTop, SourceRight, SourceBottom and physical destination DestinationLeft, DestinationTop
The PrepareXLSPortableCairoLayout(Plan, Fonts, Options) overload retains detached page records, clips and scales scene content for each tile, and uses the plan's paper dimensions and margins; raster, font, shaping and drawing budgets continue to apply to repeated content
Layout.PageCount matches the plan; PDF produces one multipage file, while SVG and PNG produce one file per logical page; the layout's text-line inspection retains unscaled snapshot coordinates rather than per-page repeated positions
Existing output files reject, and the Windows native Cairo entry point remains explicitly unsupported; see portable headless output for dependency, font mapping, scene and output limits