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
The adapter carries supported header and footer content, row and column headings, enabled print gridlines, black-and-white and draft appearance, at-end comment listings, and typed cell-error substitutions into the detached plan
Supported visible comment boxes use their source anchors and a separate page annotation layer, including notes whose boxes extend outside the printed cell range
Headers and footers
The planner places left, center and right sections in the physical header and footer margins, including distinct first-page and even-page content, page numbers and total page counts, document names, escaped ampersands, font faces, point sizes, colors, emphasis, underline, double underline, strikeout, superscript and subscript
ScaleHeaderFooterWithDocument and AlignHeaderFooterWithMargins follow worksheet page setup; repeated worksheet pages and appended comment pages share the final page-number sequence
Set HeaderFooterDateText and HeaderFooterTimeText to the intended deterministic display strings for date and time fields; the detached planner does not read the system clock while constructing each page
Theme colors use HeaderFooterThemeColors when HasHeaderFooterThemeColors is enabled; the modern workbook adapter reads that palette from the source workbook
Theme-font tokens can use explicit HeaderFooterThemeMajorFont and HeaderFooterThemeMinorFont mappings; set HeaderFooterThemeScript when the modern workbook adapter should resolve a particular supplemental script from the source theme
Supported source PNG and JPEG header pictures are captured with their source page kind, section, size, crop and offsets; drawing preserves the picture's inline position relative to adjacent text, and later picture tokens in the same section do not duplicate the image
Classic source picture records are read without changing the workbook, including available page variants; malformed records, missing picture data and unsupported appearance reject before returning a plan
Paint order, overlap and Classic image dimensions
Headers paint before worksheet body cells and drawings, while footers paint after them; supported text and images can overlap worksheet content or extend beyond physical page boundaries
The planner retains the original logical geometry and clips visible output to the physical page instead of moving the source object to fit its margin
For plain text longer than one page, the renderer retains the initial page-sized sequence of actual shaped lines before bottom-aligning a footer; the full source text and shaping work remain charged to the resource limits
TXLSPortablePrintPage.HeaderObjectCount identifies the leading header entries in HeaderFooterObjects; the remaining entries belong to the footer phase
The count must be between zero and the object-array length inclusive; zero keeps all entries after the body for a caller-supplied page without an explicit header boundary, and invalid counts reject before header/footer decoration allocation
Classic picture anchors store pixel dimensions; point dimensions are derived as pixels multiplied by 72 and divided by Workbook.RenderCalibration.MeasurementDpi, whose existing default is 96
Configure the intended measurement context explicitly when source interpretation requires another DPI; the library does not infer an absent source-machine DPI field
A matching explicit HeaderFooterPictures declaration continues to override dimensions, offsets and raster sampling, while invalid declarations retain their validation errors
The focused controls cover 96 DPI and 120 DPI contexts, explicit overrides, crop fractions, multi-record Classic PNG data, ordinary overlap and extreme plain text or image clipping
Mixed text and pictures support physical-page clipping and the source-preserving flow policy below; unknown picture effects, implicit recipient font/locale equivalence and pixel-identical print mapping remain separate boundaries
Measured recipient geometry for pictures
TXLSPortablePrintOptions.HeaderFooterRecipientMetrics captures a TXLSPortableHeaderRecipientMetrics value record; initialize options with XLSDefaultPortablePrintOptions and enable the measured context only when the intended source and recipient metrics are available
The default is disabled and retains source point geometry; no process printer, screen scaling, image metadata DPI or native export device is inferred
| Field | Contract |
|---|---|
Enabled | Enables the explicit source/recipient mapping |
QuantizeToRecipientPixels | Rounds final extents and offsets to recipient pixels after document scaling; an image that rounds to an empty extent rejects |
SourceDpi, RecipientDpi | Integer36..2400 for the corresponding measurement context |
SourceMaximumDigitWidthPixels | Maximum advance of digits0..9 in the source-context workbook Normal font, measured in source pixels |
RecipientMaximumDigitWidthPixels | Corresponding Normal-font maximum digit advance in recipient pixels |
SourceNormalLineHeightPoints | Actual default Normal line box in source points, rather than a custom worksheet row height |
RecipientNormalLineHeightPixels | Complete Normal line box in recipient pixels, including that context's line spacing and padding |
The four floating-point metrics must be finite and within1/64..1000000; measure the same intended Normal font in each context and keep each pixel measurement with its matching DPI
WidthScale = RecipientMaximumDigitWidthPixels / SourceMaximumDigitWidthPixels
* SourceDpi / RecipientDpi
HeightScale = RecipientNormalLineHeightPixels * 72 / RecipientDpi
/ SourceNormalLineHeightPoints
Width = SourceWidthPoints * DocumentScale * WidthScale
Height = SourceHeightPoints * DocumentScale * HeightScale
LeftOffset = SourceLeftOffsetPoints * DocumentScale * WidthScale
TopOffset = SourceTopOffsetPoints * DocumentScale * HeightScale
QuantizedPoints = floor(Points * RecipientDpi / 72 + 0.5) * 72 / RecipientDpi
Quantization follows the existing document scale, and the final extents and offsets must remain within the one-million-point geometry bound even after pixel rounding; no fixed scaling coefficient or guessed line padding is inserted
The measured context applies consistently to the selected odd/even/first header and footer pictures; it preserves source image bytes, crop fractions, physical page margins, source text, paint phases and clipping, while the effective picture width participates in mixed flow
Options are copied by value and result scene getters detach their arrays; fixed context storage and validation/mapping work remain charged to the existing plan budgets without retaining device handles or callbacks
An ordinary render snapshot of HeaderFooterObjects preserves mapped base scene geometry; it does not preserve the complete PrintPlan, inline link metadata or later inline-layout adjustments, and this change does not add a snapshot format version
Five independently measured Normal-font contexts qualify pure-image dimensions; marker-font spacing and the optional measured text context below also handle mixed image/text advance and line progression
Measured inline segment spacing
When the explicit recipient context is enabled, each TXLSPortableHeaderInlinePicture captures the font active at its supported &G marker, including font changes that emit no text
| Field | Contract |
|---|---|
RecipientDpi | Zero disables measured spacing; an enabled captured DPI is within36..2400 |
MarkerFontFamily | Required nonempty marker family when enabled, at most255 UTF-16 code units; the returned link array is detached |
MarkerFontSizePoints | Finite effective point size after document scaling, within1/64..4096 |
MarkerFontStyles | Captured style set; bold and italic select the corresponding explicitly supplied face |
Inactive links require empty or zero font fields; initialize records before use and rebuild dependent code for the expanded public record layout
The renderer resolves the marker family through the explicit family/style fallback chain and reads only the required two-byte OS/2.xAvgCharWidth and head.unitsPerEm fields from the selected SFNT or collection face
fontPixels = floor(markerPointSize * recipientDpi / 72 + 0.5) averagePixels = floor(fontPixels * xAvgCharWidth / unitsPerEm + 0.5) segmentPaddingPoints = floor(averagePixels / 4) * 72 / recipientDpi
The marker point size already includes document scaling; this spacing is independent of the Normal-font width ratio used for base image geometry, and no native PDF dimensions or per-picture target offsets are used as metric inputs
A prefix in the current hard paragraph contributes one image allowance even if it has moved to an earlier soft line; a suffix contributes to the image-line measure when there is no paragraph prefix or that prefix is on the image line
The suffix allowance expands the image only when both text segments share the image line; otherwise it remains a logical gap, hard breaks reset the paragraph state and color-run boundaries do not multiply the allowance
Zero-width source characters remain nonempty segments; trailing ASCII spaces remain in the captured source while they do not add suffix allowance or final measured advance
Invalid link fields, unavailable SFNT metrics, nonpositive average width and invalid units-per-em reject; explicit font coverage, font-byte limits, cancellation and existing shaping/layout limits remain in force
Family strings and link arrays remain charged during validation and copying; measuring a suffix without its trailing-space advance reserves the complete original shaped result until the temporary measurement is released
Twenty-eight native controls qualify image extents across the represented font, marker and adjacency cases; reconstructed SFNT averages do not establish equivalent GDI metrics for every font
With the text context disabled, this SFNT path retains its earlier point-layout behavior; enable the measured text context below when the intended recipient provides compatible font metrics and cumulative advances
Measured recipient text and mixed line progression
TXLSPortablePrintOptions.HeaderFooterRecipientTextContext accepts an optional TXLSPortableHeaderRecipientTextContext with Geometry, ExtraLeadingPixels and Cancellation; initialize options with XLSDefaultPortablePrintOptions before enabling it
Geometry must implement the optional IXLSRenderFontMetricSource companion and carry the captured snapshot generation; the original IXLSRenderGeometry GUID and method order are unchanged
Use a valid calibration between36 and2400 DPI, matching the image recipient DPI when image mapping is enabled; measure additional leading independently as complete Normal line height minus Normal font height and external leading, rather than assuming a fixed DPI or padding constant
ExtraLeadingPixels is finite and within0..1000000; a disabled context has nil Geometry, zero extra leading and nil Cancellation, and generation or calibration mutation during capture rejects
Bounded font metric companion
The Windows geometry implements MeasureFontMetrics(AFont) and MeasureTextAdvances(AText, AFont, AMaximumBytes, AAdvances) under its existing lock using actual selected-font measurements; another planning process can implement the same explicit companion
TXLSRenderFontMetrics contains integer HeightPixels, AscentPixels, DescentPixels, EmHeightPixels, ExternalLeadingPixels and AverageWidthPixels; ordinary width/height corrections apply to measured extents while the selected em remains the actual pixel em
TXLSRenderTextAdvances contains detached cumulative integer advances, one per UTF-16 unit; the final advance equals the returned TXLSRenderTextMetrics.WidthPixels, and no returned mutable array is retained by the provider
Advance requests accept at most32767 normalized single-line UTF-16 units, validate surrogate pairs and reject control characters; array storage is checked against AMaximumBytes before allocation, and empty text returns zero metrics and no array
Requested font families are nonempty, contain no control characters and use at most255 UTF-16 units; point sizes are finite within1/64..4096, and Windows selected-font substitution rejects rather than measuring another family
Detached capture and native layout
TXLSPortablePrintPage.HeaderRecipientTexts holds at most six uniquely indexed TXLSPortableHeaderRecipientText values with TextObjectIndex, RecipientDpi, ExtraLeadingPixels, NormalizedText, Runs, HasMarker and MarkerMetrics
Each TXLSPortableHeaderRecipientTextRun preserves one-based normalized UTF-16 SourceStart and SourceLength, source FontFamily, FontSizePoints, FontStyles, measured Metrics and cumulative Advances; intervals are contiguous and cover the complete normalized text
TXLSPortableHeaderRecipientTextRuns and TXLSPortableHeaderRecipientTexts are the corresponding array types; page getters deep-copy nested run and advance arrays, and a completed plan retains no live geometry provider
The renderer checks text, source intervals, font identity, marker association, DPI and cumulative values before retaining its own detached data; selected pixel em and logical Unicode-cluster advances drive font size, wrapping and placement
Measured ascent, descent, external leading and additional leading drive multiline text; mixed lines distinguish adjacent text, image-only soft wraps and hard breaks, while footer progression derives from its bottom anchor
Small images align with adjacent text, large images can lift the text pen, and the first residual suffix reserves the independent logical image allowance; source text, header/body/footer paint order and final physical-page clipping remain intact
Font files and their fallback chain remain explicit renderer inputs; the measured path rejects fallback to an unmeasured family, while nil Geometry retains the earlier point-layout path
Capture work and array/string reservations share MaxPlanningSteps and MaxPlanBytes; renderer temporary and retained copies share MaxLayoutBytes, with existing cancellation, shaping, glyph, line, draw and output limits still enforced
Rebuild consumers for the expanded option/page record layouts; the ordinary render-snapshot format remains unchanged and does not serialize a complete print plan or its recipient metrics
Twenty-five actual workbook outputs cover left/center/right sections, text and mixed footers, style and marker changes, hard/soft wraps and independent12/96-point image-height controls; every source character and all25 body labels remain present
In that retained comparison, baseline differences are at most0.024 pt, image placement at most0.12 pt and comparable glyph origins approximately0.309113 pt; logical measurements do not promise identical internal PDF glyph emission
Two oversize native controls discard a source character that the portable renderer retains; repeated-page, page/date token and document-scaling behavior keep their previously qualified contracts
Mixed text and picture flow
Mixed paragraphs retain fitting text and picture segments on the same line; the picture shares a line with preceding text when both fit, and following text stays beside it when the complete following segment fits the remaining line width
If the following segment needs wrapping, it starts on the next line using the section width minus the effective picture advance and any independent segment allowance, then continues with the complete section width; left, center and right alignment apply within each line's available width
A remaining width that cannot hold one complete supported Unicode cluster resumes at full section width, preserving the cluster instead of dropping a character
Text flow preserves source characters and style offsets, breaks at supported Unicode shaping-cluster boundaries and prefers existing word spaces where possible
The picture remains an atomic item with source point dimensions unless an explicit measured recipient context is enabled; a picture wider than the physical page is aligned normally and clipped without shrinking its source geometry
Wrapped text uses the physical-page clip rather than the original explicit-line-count rectangle, so newly wrapped prefixes and suffixes remain visible within the page
For content taller than one page, the renderer retains the initial page-sized sequence of shaped source lines before footer alignment; a picture belonging only to a discarded line has an empty visible clip
Every source line and glyph is prepared and charged before this page-prefix selection, and temporary arrays for the complete paragraph remain charged throughout shaping and line insertion even when only a small prefix is visible
The remaining-width rule follows the observed native flow pattern while retaining complete captured source text and explicit point geometry; the original source retains its30 A /21 Z /9 Z line division, and the optional text context supplies measured advances and vertical progression
Prepared GetTextLine inventory is limited by the existing physical-page height: source objects remain complete, but wholly page-external line records can be clipped; it is not an inventory of every character in an arbitrarily long source header
Print decorations and error policies
PrintGridlines and PrintHeadings add page-specific grid and heading geometry without modifying cell formats; repeated title rows and columns retain the matching labels
BlackAndWhite applies the print projection to detached text, borders, scene objects and decoded raster pixels; Draft omits the supported drawing and fill appearance according to the print policy
PrintErrors selects displayed errors, blank output, a dash or #N/A through xppeDisplayed, xppeBlank, xppeDash and xppeNA; substitutions use captured error identities and leave ordinary text that resembles an error unchanged
Comments at the end of a worksheet
The normal workbook entry captures source comment text and cell addresses under its read lease, selects comments associated with the print areas, sorts the listing by cell address, and avoids duplicates when areas overlap
The listing uses source font zero, including its resolved theme face, point size, emphasis and color; original comment-box rich formatting does not replace the listing font
AtEndFontOverride defaults to False; enable it only when intentionally replacing the source listing font with AtEndFont
AtEndLanguageTag and AtEndThemeScript select an explicit language or supplemental script context; an empty language context uses the Windows user interface language or the Unix locale environment, with source-font hints for a neutral locale
The source defaultThemeVersion participates in resolving the observed default font and color profiles; other version values retain the source theme rather than inheriting a guessed profile
When AtEndMeasurer is absent, the adapter creates a default text-measurement context: native GDI on Windows, or Cairo and its font providers on supported Unix targets
Unix system-font discovery checks bounded known font locations and can select the installed platform equivalent for a common Latin family; unavailable families report the missing resource, and AtEndFontFile with AtEndFontFaceIndex supplies an explicit font file or collection face
A supplied measurer must match the snapshot generation; detached line layouts retain the native font resources required for later rendering, while the finished plan does not retain the source workbook read lease
The listing preserves complete source text, wraps measured lines, and adds pages as necessary instead of silently truncating long notes; AtEndCellLabel, AtEndCommentLabel, AtEndLabelWidthPoints and AtEndNoteGapPoints customize its labels and spacing
Source capture and line measurement share the plan's byte and work limits, and AtEndCancellation permits bounded cancellation during capture and planning
TXLSPortablePrintPage.Kind distinguishes xppkWorksheet and xppkCommentsAtEnd; listing pages expose retained measured TextSlices, while worksheet pages retain their ordinary body tiles
Displayed comment boxes and at-end listings follow separate print policies; selecting one policy does not inject the other into the plan
Supported multiline headers and footers, including the mixed-content policy above, retain header/body/footer paint priority and physical-page clipping; implicit recipient font and locale parity remain separate qualification boundaries
Displayed comment boxes
The normal XLS and XLSX workbook entries capture supported visible rectangular note boxes from their actual source anchors, including source fill and outline colors, stroke width, text insets, rich font runs, text alignment and a cell-to-box leader
A note belongs to a printed page through its associated cell, rather than an intersection between its box and the printed cell range; its box can extend outside the body tile and is clipped to the physical page
Repeated title tiles can repeat notes associated with those cells, draft mode suppresses displayed notes, and monochrome worksheet printing retains the displayed note colors observed in native output
Imported source visibility is respected, while explicitly assigning the public comment visibility property overrides that visibility for capture; copying or editing general VML geometry remains a separate source-model operation
DisplayedCommentGeometry supplies an optional IXLSRenderGeometry for source anchors outside the detached body range; rows and columns inside the supplied body snapshot use that snapshot's explicit dimensions
DisplayedCommentCancellation permits cancellation during capture and planning; byte, character, item and work costs share the existing plan limits, and callbacks must preserve the workbook and active worksheet context
IXLSPortableDisplayedCommentSource.ReadPortableDisplayedCommentObjects accepts a one-based source range, an optional matching BodySnapshot, TXLSPortableRenderLimits, MaxSteps and cancellation, and reports UsedBytes, UsedCharacters, UsedSteps and UsedItems
The matching body snapshot must have the source generation and exact range dimensions; source capture holds a read lease, rejects reentrancy and context changes, and returns detached data
TXLSPortableDisplayedCommentObjects is an array of TXLSPortableDisplayedCommentObject records with a one-based Row, Column and Drawing; drawing coordinates are in points relative to the source range origin
Direct CreateXLSPortablePrintPlan callers can provide these records through DisplayedCommentObjects; text, rectangle, polyline and polygon objects are supported, while image payloads on these annotation objects are rejected
The normal workbook entries clear supplied annotation records and capture the actual workbook source; finished page records expose owned CommentObjects, with independent path and rich-text arrays on retrieval
The completed plan retains no source workbook lease, and its supported annotations can be rendered after the workbook owner is released
Unknown note appearance, missing source anchors, conflicting or unsupported color identities and unmodeled shape effects fail explicitly; ordinary worksheet drawings keep their existing capture requirements, and displayed-note support does not imply whole-sheet drawing capture
XLSX comment rich text resolves theme and RGB colors with tint, indexed palette colors, automatic colors and supported system foreground/background roles; color identities and validated tint tokens survive saving and rich-text assignment
Native comment rendering applies tint to theme and RGB selectors; indexed, automatic, empty-color and tint-only selectors retain their tint token while rendering the observed untinted color
Explicit color edits replace the old source identity, including a tint attached to the same RGB value; bold, italic and strikeout accept the standard XMLBoolean forms 1, 0, true and false
Out-of-range notes do not require anchors during capture; selected visible imported notes require supported retained geometry, while newly authored OOXML notes use the known defaults described below
The focused native profile compares presence, text, colors and fonts in actual XLS and XLSX WorkbookPrint-to-Cairo PDF output, with explicit source geometry; it does not assert pixel-identical recipient font metrics or automatic native geometry equivalence
Newly authored OOXML comments
Newly created OOXML comments support displayed-comment printing before saving and after saving and reopening, with the known default appearance shared by the writer
The default box starts 80 pt from the worksheet left edge and 5 pt from the top, with a width of 96 pt and height of 55 pt; positive explicit WidthPt and HeightPt replace those dimensions
This absolute default position does not follow the source cell or avoid other notes; notes attached to distant cells still use the same box origin
AlwaysShow controls displayed-comment visibility and newly written VML visibility; hidden comments add no displayed-comment layer
The supported default appearance includes a pale yellow frame, black shadow offset by 2 pt, source-cell leader and printed text insets of 1.8 pt horizontally and 3.6 pt vertically
Adding typed comments to a sheet with retained comment VML preserves the existing shapes and appends namespace-self-contained shapes with unused IDs
Imported comments require supported retained geometry or the recognized writer-generated no-anchor profile; missing VML, foreign default positions and duplicate CSS properties fail explicitly rather than acquiring authored defaults
Range copies retain authored provenance, while OOXML and ODS imports do not acquire it automatically; this entry does not change arbitrary imported VML edits, unrelated form controls or automatic layout
The focused final-source qualification covers actual body capture and WorkbookPrint-to-Cairo PDF output on Linux; existing RAD Studio 37.0 Win64 controls cover metadata, source capture, print planning and writer XML
Newly authored Classic XLS comments
Newly created visible Classic XLS comments support displayed printing before saving, after saving and reopening, and after changing their public width or height
The existing Classic model defaults remain 96 by 55.5 points; capture derives a local anchor from the writer's source-cell-relative placement, stored row and column sizes, hidden axes, edge fallbacks and anchor quantization
Source capture does not materialize or modify the authored comment's source anchor; the detached drawing maps the derived fractions through the caller's explicit body geometry
The ordinary enabled black shadow has a two-point offset and requires an explicit black source color; unknown system or missing enabled-shadow colors retain an appearance diagnostic
Displayed notes accept the writer's exact-cell-end fractions of 1024 horizontally and 256 vertically; ordinary worksheet drawing bounds are unchanged
Classic range copies use the existing destination AddComment path and therefore create a new default comment shape; copying raw source anchors or appearance is a separate operation
Imported comments do not acquire authored provenance; a selected visible imported note with unavailable geometry now raises explicitly instead of silently disappearing
The final focused controls cover source and print-plan behavior with existing RAD Studio 37.0 Win64, and actual WorkbookPrint-to-Cairo PDF output on Linux; native Excel controls qualify ordinary visibility, source-relative placement and black shadow appearance
Native Excel interprets quantized source anchors through its own calibration; identical pixel positions, pagination, grid appearance and text wrapping are not promised
Source and measurement interfaces
IXLSPortableAtEndCommentSource exposes ReadPortableAtEndComments and ReadPortablePrintFontZero; TXLSClassicReadOnlyWorkbookView and TXLSXReadOnlyWorkbookView implement these methods without transferring workbook ownership or modifying source formatting
ReadPortableAtEndComments returns detached TXLSPortablePrintComments, an array of TXLSPortablePrintComment records containing one-based Row and Column values and owned Text; ReadPortablePrintFontZero returns the source listing font as a TXLSPortableCell
IXLSPortablePrintFontSource.ResolvePortablePrintFontZero, implemented by TXLSXReadOnlyWorkbookView, additionally accepts Script and LanguageTag for source-theme resolution
These source methods accept TXLSPortablePrintSourceLimits with MaxComments, MaxBytes, MaxCharacters and MaxSteps, report UsedBytes, UsedCharacters and UsedSteps, and accept IXLSPortablePrintCancellation; its ShouldCancel method returns True to stop capture or planning, and callbacks must preserve the active workbook and worksheet context
IXLSPortablePrintTextMeasurer.Measure measures a detached cell at a positive WidthPoints and returns an IXLSPortablePrintTextLayout; its Generation must match the snapshot, ResidentBytes accounts for retained measurement resources, and ShapedCharacters reports shaping work
IXLSPortablePrintTextLayout.Generation identifies the matching snapshot; NormalizedText owns the measured text, WidthPoints reports the layout width, LineCount and zero-based Lines expose TXLSPortablePrintMeasuredLine records, and ResourceBytes accounts for retained resources
A measured line contains its source range and glyph count, width, height, ascent, descent and baseline in points; TXLSPortablePrintTextSlice retains a layout, FirstLine, LineCount and destination LeftPoints and TopPoints, while TXLSPortablePrintTextSlices collects slices for a TXLSPortablePrintPageKind
Header resources and appearance diagnostics
TXLSHeaderFooterVariants carries the Classic header/footer page variants used by the adapter; TXLSPortableHeaderPageKind distinguishes odd, even and first pages, and TXLSPortableHeaderThemeColors contains the twelve source theme color slots
TXLSPortableHeaderFooterPictures collects TXLSPortableHeaderFooterPicture records with page kind, section position, encoded image data, physical size and offsets, cropping, sampling and UnsupportedAppearance diagnostics
TXLSPortableHeaderInlinePictures contains TXLSPortableHeaderInlinePicture records linking a picture object to a text object and text offset, with physical offsets for inline placement
TXLSXHeaderFooterImage.PortableAppearanceSupported reports whether the captured source image appearance is modeled, and PortableAppearanceIssue describes a rejected appearance; TXLSXHeaderFooterImages.PortableSourceIssue reports collection-level source problems
TXLSXWorkbook.ResolveHeaderFooterThemeFont resolves the requested major or minor source font for a script; unsupported source theme structure reports an error instead of guessing a face
TXLSPortablePrintErrors is the detached error-output policy used by PrintErrors; its values affect captured error identities rather than ordinary text strings
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