IWorkPagesDocument
OfficeIMO.IWork
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
- Method IWorkPagesDocument.Create
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[]
- widthPoints float
- heightPoints float
- accessibilityDescription string? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
IWorkPagesImagepublic 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
- fontName string = "Arial"
- fontSizePoints float = 12
- color string = "000000"
Returns
IWorkPagesParagraphDatapublic 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
- layout OfficeIMO.IWork.IWorkPagesParagraphLayout
- fontName string = "Arial"
- fontSizePoints float = 12
- color string = "000000"
Returns
IWorkPagesParagraphDatapublic 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>
Returns
IWorkPagesParagraphDatapublic 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>
- layout OfficeIMO.IWork.IWorkPagesParagraphLayout
Returns
IWorkPagesParagraphDatapublic 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
- name string = "Table 1"
- columnWidthPoints float = 100
- rowHeightPoints float = 24
- fontName string = "Arial"
- fontSizePoints float = 12
- color string = "000000"
Returns
IWorkPagesTablepublic void ClearHeader() #Disables the header and clears its text and distance.
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
- heightPoints float = 792
- leftMarginPoints float = 72
- rightMarginPoints float = 72
- topMarginPoints float = 72
- bottomMarginPoints float = 72
Returns
IWorkPagesDocumentpublic static IWorkPagesDocument Create(string path) #Creates a native authoring model associated with a path, without writing a file.
Parameters
- path string
Returns
IWorkPagesDocumentpublic IWorkPagesNumberedList CreateNumberedList(string fontName = "Arial", float fontSizePoints = 12) #Creates a decimal list; call AddItem or AddRichItem to insert body paragraphs.
Parameters
- fontName string = "Arial"
- fontSizePoints float = 12
Returns
IWorkPagesNumberedListpublic 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
- fontName string = "Arial"
- fontSizePoints float = 12
Returns
IWorkPagesNumberedListpublic void Dispose() #Completes this managed authoring model's lifetime. No native application, file or caller stream is retained.
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
- options OfficeIMO.IWork.IWorkPagesSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
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
- overwrite bool = false
- options OfficeIMO.IWork.IWorkPagesSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
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
- options OfficeIMO.IWork.IWorkPagesSaveOptions? = null
- cancellationToken System.Threading.CancellationToken = default
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
- fontName string = "Arial"
- fontSizePoints float = 12
- color string = "000000"
- distancePoints float = 36
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
- distancePoints float = 36
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
- cancellationToken System.Threading.CancellationToken = default
Returns
byte[]Inherited Methods
Properties
public float LeftMarginPoints { get; } #Gets the left body margin in points.
public float RightMarginPoints { get; } #Gets the right 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.