Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

IWorkPagesDocument

OfficeIMO.IWork

Namespace
OfficeIMO.IWork
Assembly
OfficeIMO.IWork
Source revision
273d35d5ba8a with working tree changes
Implements
IDisposable
Modifiers
sealed

Creates template-free native Pages documents with page settings, headers/footers, rich body paragraphs, images and scalar tables.

Inheritance

  • object
  • IWorkPagesDocument

Remarks

Instances are not thread safe. This model does not modify loaded packages or measure pagination.

Usage

Explore 1 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.

Returned or exposed by 1

Methods

public IWorkPagesImage AddImage(byte[] data, float widthPoints, float heightPoints, string? accessibilityDescription = null, CancellationToken cancellationToken = default) #

Adds a validated PNG or JPEG snapshot as its own inline body paragraph.

Parameters

data byte[] required
widthPoints float required
heightPoints float required
accessibilityDescription string? = null optional
cancellationToken System.Threading.CancellationToken = default optional
AddParagraph 2 overloads
public IWorkPagesParagraphData AddParagraph(string text, string fontName = "Arial", float fontSizePoints = 12, string color = "000000") #

Adds a left-aligned body paragraph with one font and opaque sRGB color.

Parameters

text string required
fontName string = "Arial" optional
fontSizePoints float = 12 optional
color string = "000000" optional
public IWorkPagesParagraphData AddParagraph(string text, IWorkPagesParagraphLayout layout, string fontName = "Arial", float fontSizePoints = 12, string color = "000000") #

Adds a body paragraph with immutable layout and one font. TAB characters use its native tab stops.

Parameters

text string required
layout OfficeIMO.IWork.IWorkPagesParagraphLayout required
fontName string = "Arial" optional
fontSizePoints float = 12 optional
color string = "000000" optional
AddRichParagraph 2 overloads
public IWorkPagesParagraphData AddRichParagraph(IEnumerable<IWorkTextRunData> runs) #

Adds a snapshot of rich character runs as one left-aligned body paragraph.

Parameters

runs System.Collections.Generic.IEnumerable<OfficeIMO.IWork.IWorkTextRunData> required
public IWorkPagesParagraphData AddRichParagraph(IEnumerable<IWorkTextRunData> runs, IWorkPagesParagraphLayout layout) #

Adds a snapshot of rich runs with immutable paragraph spacing and custom tabs.

Parameters

runs System.Collections.Generic.IEnumerable<OfficeIMO.IWork.IWorkTextRunData> required
layout OfficeIMO.IWork.IWorkPagesParagraphLayout required
public IWorkPagesTable AddTable(IWorkTableData data, string name = "Table 1", float columnWidthPoints = 100, float rowHeightPoints = 24, string fontName = "Arial", float fontSizePoints = 12, string color = "000000") #

Adds a snapshot of scalar data as an inline body table with equally sized rows and columns.

Parameters

data OfficeIMO.IWork.IWorkTableData required
name string = "Table 1" optional
columnWidthPoints float = 100 optional
rowHeightPoints float = 24 optional
fontName string = "Arial" optional
fontSizePoints float = 12 optional
color string = "000000" optional
public void ClearFooter() #

Disables the footer and clears its text and distance.

public void ClearHeader() #

Disables the header and clears its text and distance.

Create 2 overloads
public static IWorkPagesDocument Create(float widthPoints = 612, float heightPoints = 792, float leftMarginPoints = 72, float rightMarginPoints = 72, float topMarginPoints = 72, float bottomMarginPoints = 72) #

Creates an empty document, using US Letter and one-inch margins by default.

Parameters

widthPoints float = 612 optional
heightPoints float = 792 optional
leftMarginPoints float = 72 optional
rightMarginPoints float = 72 optional
topMarginPoints float = 72 optional
bottomMarginPoints float = 72 optional
public static IWorkPagesDocument Create(string path) #

Creates a native authoring model associated with a path, without writing a file.

Parameters

path string required
CreateNumberedList 2 overloads
public IWorkPagesNumberedList CreateNumberedList(string fontName = "Arial", float fontSizePoints = 12) #

Creates a decimal list; call AddItem or AddRichItem to insert body paragraphs.

Parameters

fontName string = "Arial" optional
fontSizePoints float = 12 optional
public IWorkPagesNumberedList CreateNumberedList(IWorkDecimalListMarkerStyle markerStyle, string fontName = "Arial", float fontSizePoints = 12) #

Creates a decimal list with the selected marker punctuation at every level.

Parameters

markerStyle OfficeIMO.IWork.IWorkDecimalListMarkerStyle required
fontName string = "Arial" optional
fontSizePoints float = 12 optional
public void Dispose() #

Completes this managed authoring model's lifetime. No native application, file or caller stream is retained.

Save 3 overloads
public void Save(Stream destination, IWorkPagesSaveOptions? options = null, CancellationToken cancellationToken = default) #

Writes a completed package at the stream's current position and leaves the stream open.

Parameters

destination System.IO.Stream required
options OfficeIMO.IWork.IWorkPagesSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public void Save(string path, bool overwrite = false, IWorkPagesSaveOptions? options = null, CancellationToken cancellationToken = default) #

Atomically saves a native package, rejecting an existing file unless overwrite is enabled.

Parameters

path string required
overwrite bool = false optional
options OfficeIMO.IWork.IWorkPagesSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public void Save(bool overwrite = false, IWorkPagesSaveOptions? options = null, CancellationToken cancellationToken = default) #

Saves to the associated path; replacing an existing file still requires explicit overwrite.

Parameters

overwrite bool = false optional
options OfficeIMO.IWork.IWorkPagesSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
SetFooter 2 overloads
public void SetFooter(string text, string fontName = "Arial", float fontSizePoints = 12, string color = "000000", float distancePoints = 36) #

Sets one left-aligned footer paragraph for every page in the document's single section.

Parameters

text string required
fontName string = "Arial" optional
fontSizePoints float = 12 optional
color string = "000000" optional
distancePoints float = 36 optional
public void SetFooter(IWorkTextRunData run, float distancePoints = 36) #

Sets a snapshot of one immutable character run as the left footer for every page.

Parameters

run OfficeIMO.IWork.IWorkTextRunData required
distancePoints float = 36 optional
SetHeader 2 overloads
public void SetHeader(string text, string fontName = "Arial", float fontSizePoints = 12, string color = "000000", float distancePoints = 36) #

Sets one left-aligned header paragraph for every page in the document's single section.

Parameters

text string required
fontName string = "Arial" optional
fontSizePoints float = 12 optional
color string = "000000" optional
distancePoints float = 36 optional
public void SetHeader(IWorkTextRunData run, float distancePoints = 36) #

Sets a snapshot of one immutable character run as the left header for every page.

Parameters

run OfficeIMO.IWork.IWorkTextRunData required
distancePoints float = 36 optional
public byte[] ToBytes(IWorkPagesSaveOptions? options = null, CancellationToken cancellationToken = default) #

Encodes a deterministic native Pages package without a template or native application.

Parameters

options OfficeIMO.IWork.IWorkPagesSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

byte[]

Properties

public IWorkCanvasSize PageSize { get; } #

Gets page dimensions in points.

public float LeftMarginPoints { get; } #

Gets the left body margin in points.

public float RightMarginPoints { get; } #

Gets the right body margin in points.

public float TopMarginPoints { get; } #

Gets the top body margin in points.

public float BottomMarginPoints { get; } #

Gets the bottom body margin in points.

public IReadOnlyList<IWorkPagesParagraphData> Paragraphs { get; } #

Gets the body paragraphs in insertion order.

public IReadOnlyList<IWorkPagesTable> Tables { get; } #

Gets authored inline tables in insertion order.

public IReadOnlyList<IWorkPagesImage> Images { get; } #

Gets authored inline images in insertion order.

public IReadOnlyList<IWorkPagesNumberedList> NumberedLists { get; } #

Gets the document's decimal lists. Empty lists do not create body content or native styles.

public IReadOnlyList<IWorkPagesBodyBlock> BodyBlocks { get; } #

Gets paragraphs, images and tables in their shared body order.

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

Gets the associated output path; stream saves do not change it.

public IWorkTextRunData? Header { get; private set; } #

Gets the immutable left header run, or null when headers are disabled.

public float HeaderDistancePoints { get; private set; } #

Gets the native header distance from the page's top edge, in points.

public float FooterDistancePoints { get; private set; } #

Gets the native footer distance from the page's bottom edge, in points.