Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

PublisherDocument

OfficeIMO.Publisher

Namespace
OfficeIMO.Publisher
Assembly
OfficeIMO.Publisher
Source revision
0eef6a5756b9 with working tree changes
Implements
IDisposable
Modifiers
sealed

A managed editable publication, loaded from Publisher or created in memory, with bounded native source saving and SVG export.

Inheritance

  • object
  • PublisherDocument

Usage

Explore 11 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 8

Methods

AddImage 2 overloads
public PublisherPicture AddImage(uint pageId, byte[] bytes, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Appends an owned static PNG or JPEG picture to a qualified document or master page and returns its committed immutable snapshot. Bounds use physical page-local lengths and positive dimensions.

Parameters

pageId uint required
bytes byte[] required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public PublisherPicture AddImage(uint pageId, int imageId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Appends an uncropped picture that shares an existing document image asset. Bounds use physical page-local lengths.

Parameters

pageId uint required
imageId int required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public PublisherTextFrame AddLinkedTextFrame(uint previousFrameId, uint pageId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Appends a new continuation frame to an existing resolved non-table story, on an existing document page. Returns the current snapshot of the new frame.

Parameters

previousFrameId uint required
pageId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public PublisherPage AddMasterPage(string name, CancellationToken cancellationToken = default) #

Appends an empty centered single-page master at the publication's existing size, returning its committed immutable snapshot. The name must contain non-control text.

Parameters

name string required
cancellationToken System.Threading.CancellationToken = default optional
public ValueTuple<PublisherPage, PublisherPage> AddMasterPagePair(string name, CancellationToken cancellationToken = default) #

Appends both definitions of a two-page master atomically and returns their committed immutable snapshots.

Parameters

name string required
cancellationToken System.Threading.CancellationToken = default optional

Returns

ValueTuple<PublisherPage, PublisherPage>
public PublisherPage AddPage(uint? masterPageId = null, CancellationToken cancellationToken = default) #

Appends an empty document page at the publication's existing size. A null master identifier means no applied master. Returns the committed immutable page snapshot.

Parameters

masterPageId uint? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public PublisherShape AddShape(uint pageId, OfficeShape shape, OfficeLength x, OfficeLength y, CancellationToken cancellationToken = default) #

Appends a rectangle, rounded rectangle, ellipse or nondegenerate line to an existing document or master page, returning its current immutable snapshot.

Parameters

pageId uint required
shape OfficeIMO.Drawing.OfficeShape required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public PublisherTable AddTable(uint pageId, OfficeLength x, OfficeLength y, IReadOnlyList<OfficeLength> columnWidths, IReadOnlyList<OfficeLength> rowHeights, CancellationToken cancellationToken = default) #

Appends an empty, unmerged, borderless table to an existing qualified document or master page. Track sizes and offsets use physical lengths. Returns the current immutable snapshot.

Parameters

pageId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
columnWidths System.Collections.Generic.IReadOnlyList<OfficeIMO.OfficeLength> required
rowHeights System.Collections.Generic.IReadOnlyList<OfficeIMO.OfficeLength> required
cancellationToken System.Threading.CancellationToken = default optional
public PublisherTextFrame AddTextFrame(uint pageId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, IReadOnlyList<OfficeRichTextParagraph> paragraphs, CancellationToken cancellationToken = default) #

Appends an independent styled text frame and complete story to a qualified document or master page. Bounds are page-local physical lengths; dimensions must be positive. Returns the committed immutable frame snapshot.

Parameters

pageId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
paragraphs System.Collections.Generic.IReadOnlyList<OfficeIMO.Drawing.OfficeRichTextParagraph> required
cancellationToken System.Threading.CancellationToken = default optional
Create 2 overloads
public static PublisherDocument Create(PublisherCreateOptions? options = null, CancellationToken cancellationToken = default) #

Creates an in-memory publication with one empty document page, defaulting to A4 portrait, no applied master and no native source.

Parameters

options OfficeIMO.Publisher.PublisherCreateOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public static PublisherDocument Create(OfficeLength width, OfficeLength height, PublisherCreateOptions? options = null, CancellationToken cancellationToken = default) #

Creates an in-memory publication with one empty document page at the given positive physical dimensions, no applied master and no native source.

Parameters

width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
options OfficeIMO.Publisher.PublisherCreateOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public void Dispose() #

Completes the document lifetime without changing detached snapshots or disposing caller-owned codecs and font providers. No owned handles are retained.

Load 3 overloads
public static PublisherDocument Load(string path, PublisherLoadOptions? options = null, CancellationToken cancellationToken = default) #

Loads a publication from a file without retaining file handles.

Parameters

path string required
options OfficeIMO.Publisher.PublisherLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public static PublisherDocument Load(byte[] bytes, PublisherLoadOptions? options = null, CancellationToken cancellationToken = default) #

Loads bounded native publication bytes. Unsupported generations and malformed records are rejected.

Parameters

bytes byte[] required
options OfficeIMO.Publisher.PublisherLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public static PublisherDocument Load(Stream stream, PublisherLoadOptions? options = null, CancellationToken cancellationToken = default) #

Reads from the current position to EOF, leaving the caller's stream open. Non-seekable streams are supported.

Parameters

stream System.IO.Stream required
options OfficeIMO.Publisher.PublisherLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
LoadAsync 2 overloads
public static async Task<PublisherDocument> LoadAsync(string path, PublisherLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously reads bounded publication bytes from a file, then parses and projects them with cancellation. No file handle is retained.

Parameters

path string required
options OfficeIMO.Publisher.PublisherLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<PublisherDocument>
public static async Task<PublisherDocument> LoadAsync(Stream stream, PublisherLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously reads bounded native bytes from the current position to EOF, then parses and projects them. Caller-owned and non-seekable streams remain open.

Parameters

stream System.IO.Stream required
options OfficeIMO.Publisher.PublisherLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<PublisherDocument>
public void MergeTableCells(uint tableId, int firstRow, int firstColumn, int rowCount, int columnCount, CancellationToken cancellationToken = default) #

Merges a rectangular range of complete cells in an authored table, using zero-based coordinates and positive row and column counts.

Parameters

tableId uint required
firstRow int required
firstColumn int required
rowCount int required
columnCount int required
cancellationToken System.Threading.CancellationToken = default optional
public void ReplacePictureImage(uint pictureId, byte[] bytes, CancellationToken cancellationToken = default) #

Replaces one supported picture placement's embedded image with owned PNG or JPEG bytes. Other placements sharing its old asset remain unchanged.

Parameters

pictureId uint required
bytes byte[] required
cancellationToken System.Threading.CancellationToken = default optional
public void ReplaceStoryParagraphs(uint storyId, IReadOnlyList<OfficeRichTextParagraph> paragraphs, CancellationToken cancellationToken = default) #

Replaces a non-table story's styled paragraphs and recalculates its page layout. IDs and frame links are retained. Fetch current pages, stories and frames after an edit; previously returned objects remain snapshots.

Parameters

storyId uint required
paragraphs System.Collections.Generic.IReadOnlyList<OfficeIMO.Drawing.OfficeRichTextParagraph> required
cancellationToken System.Threading.CancellationToken = default optional
public void ReplaceTableCellParagraphs(uint tableId, int rowIndex, int columnIndex, IReadOnlyList<OfficeRichTextParagraph> paragraphs, CancellationToken cancellationToken = default) #

Replaces the styled paragraphs of the cell anchored at the given zero-based grid coordinates. Other cells, merged ownership and the complete story remain intact.

Parameters

tableId uint required
rowIndex int required
columnIndex int required
paragraphs System.Collections.Generic.IReadOnlyList<OfficeIMO.Drawing.OfficeRichTextParagraph> required
cancellationToken System.Threading.CancellationToken = default optional
Save 3 overloads
public PublisherSaveReport Save(PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Atomically saves to the associated native path, replacing that file by default. Explicit settings retain their selected conflict policy.

Parameters

options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public PublisherSaveReport Save(string path, PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Prepares a complete native PUB and atomically publishes it to an explicit .pub path.

Parameters

path string required
options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public PublisherSaveReport Save(Stream stream, PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Prepares native PUB bytes before writing a caller-owned stream, which remains open.

Parameters

stream System.IO.Stream required
options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
SaveAsync 3 overloads
public Task<PublisherSaveReport> SaveAsync(PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously stages and atomically saves to the associated native path, replacing that file by default. Explicit settings retain their selected conflict policy.

Parameters

options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<PublisherSaveReport>
public async Task<PublisherSaveReport> SaveAsync(string path, PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously stages and atomically publishes a complete native PUB to an explicit .pub path.

Parameters

path string required
options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<PublisherSaveReport>
public async Task<PublisherSaveReport> SaveAsync(Stream stream, PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously writes a complete native PUB to a caller-owned stream without closing it.

Parameters

stream System.IO.Stream required
options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<PublisherSaveReport>
public void SetPageMaster(uint pageId, uint? masterPageId, CancellationToken cancellationToken = default) #

Assigns a qualified direct master to a document page, or clears the assignment when the master identifier is null. Inherited objects remain owned once by their master.

Parameters

pageId uint required
masterPageId uint? required
cancellationToken System.Threading.CancellationToken = default optional
public void SetPageObjectOrder(uint pageId, IReadOnlyList<uint> objectIds, CancellationToken cancellationToken = default) #

Sets an existing document or master page's back-to-front object order. Supply every identifier from its current PublisherPage.ObjectIds exactly once.

Parameters

pageId uint required
objectIds System.Collections.Generic.IReadOnlyList<uint> required
cancellationToken System.Threading.CancellationToken = default optional
public void SetPictureBounds(uint pictureId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Sets a supported picture's physical page-local bounds. Negative offsets allow page-clipped bleed; width and height must be positive.

Parameters

pictureId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public void SetPictureCrop(uint pictureId, OfficeImageSourceCrop crop, CancellationToken cancellationToken = default) #

Sets normalized source-edge crop fractions on one supported picture without changing its frame or embedded image.

Parameters

pictureId uint required
crop OfficeIMO.Drawing.OfficeImageSourceCrop required
cancellationToken System.Threading.CancellationToken = default optional
public void SetShapeBounds(uint shapeId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Moves or resizes supported vector artwork using physical page-local bounds. Text-capable artwork shares its current placement with the text frame of the same ID.

Parameters

shapeId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public void SetShapePaint(uint shapeId, OfficeColor? fillColor, OfficeColor? strokeColor, OfficeLength? strokeWidth = null, double fillOpacity = 1, double strokeOpacity = 1, CancellationToken cancellationToken = default) #

Replaces the supported shape's basic solid fill and outline. Null colors disable that paint; physical stroke width defaults to one point and opacities must be between zero and one.

Parameters

shapeId uint required
fillColor OfficeIMO.OfficeColor? required
strokeColor OfficeIMO.OfficeColor? required
strokeWidth OfficeIMO.OfficeLength? = null optional
fillOpacity double = 1 optional
strokeOpacity double = 1 optional
cancellationToken System.Threading.CancellationToken = default optional
public void SetStoryAutomaticHyphenation(uint storyId, bool enabled, CancellationToken cancellationToken = default) #

Sets an ordinary story's native automatic-hyphenation flag without changing its source text or formatting.

Parameters

storyId uint required
enabled bool required
cancellationToken System.Threading.CancellationToken = default optional
public void SetTableBorderStyle(uint tableId, int firstRow, int firstColumn, int lastRow, int lastColumn, OfficeBorderSide? side, CancellationToken cancellationToken = default) #

Assigns an opaque solid border, or clears it with null, along an ordered horizontal or vertical range of grid boundaries.

Parameters

tableId uint required
firstRow int required
firstColumn int required
lastRow int required
lastColumn int required
side OfficeIMO.Drawing.OfficeBorderSide? required
cancellationToken System.Threading.CancellationToken = default optional
public void SetTableBounds(uint tableId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Moves and proportionally resizes a qualified table using physical page-local bounds, scaling its column and row tracks by the frame's width and height ratios.

Parameters

tableId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public void SetTableCellFillColor(uint tableId, int rowIndex, int columnIndex, OfficeColor? color, CancellationToken cancellationToken = default) #

Sets the opaque solid fill, or clears the fill, of the cell anchored at the given zero-based coordinates.

Parameters

tableId uint required
rowIndex int required
columnIndex int required
color OfficeIMO.OfficeColor? required
cancellationToken System.Threading.CancellationToken = default optional
public void SetTextFrameBounds(uint frameId, OfficeLength x, OfficeLength y, OfficeLength width, OfficeLength height, CancellationToken cancellationToken = default) #

Sets a visible, resolved, untransformed top-level text frame's physical page-local bounds and recalculates the publication. Negative page offsets allow clipped bleed; width and height must be positive.

Parameters

frameId uint required
x OfficeIMO.OfficeLength required
y OfficeIMO.OfficeLength required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
cancellationToken System.Threading.CancellationToken = default optional
public void SetTextFrameLayout(uint frameId, int columnCount, OfficeLength columnSpacing, OfficeTextPadding padding, OfficeTextVerticalAlignment verticalAlignment, CancellationToken cancellationToken = default) #

Replaces a qualified text frame's column count, physical gap, insets and vertical alignment, then recalculates current text ranges, overflow and page scenes. Padding retains its drawing-owned point coordinates.

Parameters

frameId uint required
columnCount int required
columnSpacing OfficeIMO.OfficeLength required
padding OfficeIMO.Drawing.OfficeTextPadding required
verticalAlignment OfficeIMO.Drawing.OfficeTextVerticalAlignment required
cancellationToken System.Threading.CancellationToken = default optional
ToBytes 2 overloads
public byte[] ToBytes(PublisherSaveOptions? options = null, CancellationToken cancellationToken = default) #

Prepares caller-owned native PUB bytes under the selected loss policy.

Parameters

options OfficeIMO.Publisher.PublisherSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

byte[]
public byte[] ToBytes(PublisherSaveOptions? options, out PublisherSaveReport report, CancellationToken cancellationToken = default) #

Prepares caller-owned native PUB bytes and returns the save report.

Parameters

options OfficeIMO.Publisher.PublisherSaveOptions? required
report OfficeIMO.Publisher.PublisherSaveReport required
cancellationToken System.Threading.CancellationToken = default optional

Returns

byte[]
ToSvg 2 overloads
public string ToSvg(int pageIndex, PublisherSvgOptions? options, out OfficeConversionReport report, CancellationToken cancellationToken = default) #

Exports one document page, selected by zero-based index, with combined source and rendering diagnostics.

Parameters

pageIndex int required
options OfficeIMO.Publisher.PublisherSvgOptions? required
report OfficeIMO.OfficeConversionReport required
cancellationToken System.Threading.CancellationToken = default optional

Returns

string
public string ToSvg(int pageIndex = 0, PublisherSvgOptions? options = null, CancellationToken cancellationToken = default) #

Exports one document page as SVG. Use the report overload to inspect source and rendering losses before accepting output.

Parameters

pageIndex int = 0 optional
options OfficeIMO.Publisher.PublisherSvgOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

string

Properties

public bool HasNativeSource { get; } #

Whether this document was loaded from native publication bytes. In-memory edits and added pages do not change this provenance.

public string? FilePath { get; private set; } #

Absolute path of the loaded file or most recent successful native path save. Stream operations do not associate a path.

public IReadOnlyList<PublisherPage> Pages { get; private set; } #

Document pages in current publication order. Utility pages and master definitions are excluded.

public IReadOnlyList<PublisherPage> MasterPages { get; private set; } #

Current master definitions, also projected onto their referring document pages.

public IReadOnlyList<PublisherTextStory> TextStories { get; private set; } #

Complete current text stories, including authored stories and content whose placement could not be reconstructed.

public IReadOnlyList<PublisherImage> Images { get; private set; } #

Recovered embedded image payloads.

public PublisherReadReport ReadReport { get; private set; } #

Source decoding and current page reconstruction report. Successful edits replace this snapshot with fresh projection evidence.

public PublisherReadReport SourceReadReport { get; private set; } #

Immutable native decoding evidence captured before the initial page projection, or zero source evidence for source-free creation. Edits do not replace this snapshot.

Extension Methods

public static OfficeConversionReport SaveAsImages(PublisherDocument document, string folderPath, OfficeImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Saves selected pages with atomic files, bounded output and fidelity acceptance.

Parameters

document OfficeIMO.Publisher.PublisherDocument required
folderPath string required
options OfficeIMO.Drawing.OfficeImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeConversionReport
public static async Task<OfficeConversionReport> SaveAsImagesAsync(PublisherDocument document, string folderPath, OfficeImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Saves selected pages asynchronously without retaining completed image payloads.

Parameters

document OfficeIMO.Publisher.PublisherDocument required
folderPath string required
options OfficeIMO.Drawing.OfficeImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<OfficeConversionReport>
ToImages 2 overloads
public static IReadOnlyList<OfficeImageExportResult> ToImages(PublisherDocument document, OfficeImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Renders selected source pages in caller order, retaining source and encoding diagnostics.

Parameters

document OfficeIMO.Publisher.PublisherDocument required
options OfficeIMO.Drawing.OfficeImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

IReadOnlyList<OfficeImageExportResult>
public static void ToImages(PublisherDocument document, OfficeImageExportConsumer consumer, OfficeImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Streams selected images without retaining earlier encoded payloads.

Parameters

document OfficeIMO.Publisher.PublisherDocument required
consumer OfficeIMO.Drawing.OfficeImageExportConsumer required
options OfficeIMO.Drawing.OfficeImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public static Task<IReadOnlyList<OfficeImageExportResult>> ToImagesAsync(PublisherDocument document, OfficeImageExportOptions? options = null, CancellationToken cancellationToken = default) #

Renders selected source pages asynchronously with shared cancellation and deadlines.

Parameters

document OfficeIMO.Publisher.PublisherDocument required
options OfficeIMO.Drawing.OfficeImageExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<IReadOnlyList<OfficeImageExportResult>>