Class DocxDocument
- Namespace
- PDiffy
- Assembly
- PDiffy.dll
Everything PDiffy reads from a Word document (DOCX), in the order a snapshot prints it.
public sealed record DocxDocument : IEquatable<DocxDocument>
- Inheritance
-
DocxDocument
- Implements
- Inherited Members
Properties
Body
Paragraphs, tables, content controls, inserted documents, bookmarks between them and content PDiffy can't read, in reading order.
public IReadOnlyList<DocxBlock> Body { get; init; }
Property Value
Document
Document-wide details: title, language, compatibility, protection and unreadable parts.
public required DocxDocumentInfo Document { get; init; }
Property Value
Footers
Each section's footers, by kind.
public IReadOnlyList<DocxHeaderFooter> Footers { get; init; }
Property Value
Headers
Each section's headers, by kind.
public IReadOnlyList<DocxHeaderFooter> Headers { get; init; }
Property Value
Lists
The lists the document uses, each with the levels it uses.
public IReadOnlyList<DocxList> Lists { get; init; }
Property Value
Notes
Footnotes, endnotes and comments, with what each says.
public IReadOnlyList<DocxNote> Notes { get; init; }
Property Value
PageSetups
Each section's page size, margins, columns and page numbering, in document order.
public IReadOnlyList<DocxPageSetup> PageSetups { get; init; }
Property Value
Styles
The styles the document uses, with their properties resolved through the styles they're based on.
public IReadOnlyList<DocxStyle> Styles { get; init; }
Property Value
Methods
Check(DocxCheckSet)
Applies the rules in a set, such as Latest, and lists what they find as Check(params DocxCheck[]) does.
public IReadOnlyList<DocxCheckFinding> Check(DocxCheckSet set)
Parameters
setDocxCheckSet
Returns
Check(params DocxCheck[])
Applies the checks and lists what they find, grouped by check in the order DocxCheck declares them and then in snapshot order; an empty list means every check passed. With no checks given, applies every check.
public IReadOnlyList<DocxCheckFinding> Check(params DocxCheck[] checks)
Parameters
checksDocxCheck[]
Returns
CompareTo(DocxDocument, Action<DocxSnapshotOptions>?)
The differences between this document's snapshot and a later one's, element by element, as Compare(DocxDocument, DocxDocument, Action<DocxSnapshotOptions>?) gives them.
public DocumentDiff CompareTo(DocxDocument after, Action<DocxSnapshotOptions>? configure = null)
Parameters
afterDocxDocumentThe later document, whose new content counts as added.
configureAction<DocxSnapshotOptions>What to leave out or scrub from both, as for ToSnapshot(Action<DocxSnapshotOptions>?).
Returns
Images()
Every image and other graphic (chart, diagram, shape) in the body, headers, footers and notes, for example, to check alt text.
public IEnumerable<DocxImage> Images()
Returns
Load(byte[])
Reads the DOCX in a byte array.
public static DocxDocument Load(byte[] docx)
Parameters
docxbyte[]
Returns
Load(Stream)
Reads the DOCX in a stream from its start, wherever the stream was left, and puts its position back afterward. The stream is left open.
public static DocxDocument Load(Stream docx)
Parameters
docxStream
Returns
Remarks
A part that can't be read is listed in UnreadableParts; a file that can't be opened throws. An empty stream, a PDF or a web page throws InvalidDataException saying so.
Load(string)
Reads the DOCX file at a path.
public static DocxDocument Load(string path)
Parameters
pathstring
Returns
Paragraphs()
Every paragraph of the body in reading order, including those inside tables, content controls, text boxes and inserted documents.
public IEnumerable<DocxParagraph> Paragraphs()
Returns
Revisions()
The tracked changes in the body, headers, footers and notes, including inserted documents, for example to check that none shipped: insertions, deletions, moves and formatting changes to text and paragraphs (paragraph marks included) and changes to tables, rows and cells, followed by changes to section settings.
public IEnumerable<DocxRevision> Revisions()
Returns
ToSnapshot(Action<DocxSnapshotOptions>?)
The canonical snapshot text: one paragraph, table cell or style per line, LF endings.
public string ToSnapshot(Action<DocxSnapshotOptions>? configure = null)
Parameters
configureAction<DocxSnapshotOptions>What to leave out or scrub, e.g.
o => o.Ignore(DocxSection.Styles).ScrubDates().
Returns
ToTranscript()
The body as the lines a screen reader announces, in reading order, such as "heading level 1: Trail Guide" and "figure: Park logo", in the same shape as ToTranscript(). Pass it to VerifyTextAsync(string, Action<TextSnapshotOptions>?, string, string) for a test that fails when what a screen reader user hears changes.
public string ToTranscript()