• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class PageContent

The drawing surface for a PDF page. Accumulates drawing operations that are serialized to a content stream on Save(Stream).

Inheritance
object
PageContent
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: DRIT.Pdf.Content
Assembly: DRIT.Pdf.dll
Syntax
public sealed class PageContent

Properties

Elements

Access the page's content-element collection (paths, images, etc.).

Declaration
public ContentElementCollection Elements { get; }
Property Value
Type Description
ContentElementCollection

Methods

AddAxialShading(double, double, double, double, double, double, double, double, List<(double t, PdfColor c)>)

Add a PDF Type-2 axial shading (linear gradient) bounded by the given clipping rectangle. clipX, clipY are the PDF bottom-left of the clip rect. (x0, y0) and (x1, y1) are the axis endpoints in PDF page coordinates (t=0 and t=1 respectively). stops are (position 0–1, PdfColor) pairs in ascending position order.

Declaration
public void AddAxialShading(double clipX, double clipY, double clipW, double clipH, double x0, double y0, double x1, double y1, List<(double t, PdfColor c)> stops)
Parameters
Type Name Description
double clipX
double clipY
double clipW
double clipH
double x0
double y0
double x1
double y1
List<(double t, PdfColor c)> stops

BeginLayer(OptionalContentGroup)

Begin an optional-content group (layer) section. All subsequent drawing operations until the matching EndLayer() call are placed inside this OCG.

Declaration
public void BeginLayer(OptionalContentGroup group)
Parameters
Type Name Description
OptionalContentGroup group

DrawAnnotation(FormField)

Draw a form field's visual content at the field's page position. Use this when flattening an AcroForm: call for each field, then Fields.Clear(), then Save.

Declaration
public void DrawAnnotation(FormField field)
Parameters
Type Name Description
FormField field

DrawImage(PdfImage, PdfMatrix)

Draw a PdfImage using a custom transform matrix.

Declaration
public void DrawImage(PdfImage image, PdfMatrix matrix)
Parameters
Type Name Description
PdfImage image
PdfMatrix matrix

DrawImage(PdfImage, PdfPoint)

Draw a PdfImage at the given bottom-left origin at its natural size.

Declaration
public void DrawImage(PdfImage image, PdfPoint point)
Parameters
Type Name Description
PdfImage image
PdfPoint point

DrawImage(PdfImage, PdfPoint, PdfSize)

Draw a PdfImage scaled to the given size.

Declaration
public void DrawImage(PdfImage image, PdfPoint point, PdfSize size)
Parameters
Type Name Description
PdfImage image
PdfPoint point
PdfSize size

DrawImageClipped(PdfImage, PdfMatrix, double, double, double, double)

Draws an image using a transform matrix and an axis-aligned clip rectangle.

Declaration
public void DrawImageClipped(PdfImage image, PdfMatrix matrix, double clipX, double clipY, double clipWidth, double clipHeight)
Parameters
Type Name Description
PdfImage image
PdfMatrix matrix
double clipX
double clipY
double clipWidth
double clipHeight

DrawImageClipped(PdfImage, PdfPoint, PdfSize, double, double, double, double)

Draws an image clipped to an axis-aligned PDF rectangle.

Declaration
public void DrawImageClipped(PdfImage image, PdfPoint point, PdfSize size, double clipX, double clipY, double clipWidth, double clipHeight)
Parameters
Type Name Description
PdfImage image
PdfPoint point
PdfSize size
double clipX
double clipY
double clipWidth
double clipHeight

DrawTable(Table, PdfPoint)

Draw a table DOM starting from a top-left position on the current page.

Declaration
public TableRenderResult DrawTable(Table table, PdfPoint topLeft)
Parameters
Type Name Description
Table table
PdfPoint topLeft
Returns
Type Description
TableRenderResult

DrawTable(Table, PdfPoint, TableRenderOptions?)

Draw a table DOM with optional render options (for example row slicing).

Declaration
public TableRenderResult DrawTable(Table table, PdfPoint topLeft, TableRenderOptions? options)
Parameters
Type Name Description
Table table
PdfPoint topLeft
TableRenderOptions options
Returns
Type Description
TableRenderResult

DrawText(FormattedText, PdfMatrix)

Draw formatted text using a transform matrix.

Declaration
public void DrawText(FormattedText text, PdfMatrix matrix)
Parameters
Type Name Description
FormattedText text
PdfMatrix matrix

DrawText(FormattedText, PdfPoint)

Draw formatted text at the given point (bottom-left of text block).

Declaration
public void DrawText(FormattedText text, PdfPoint point)
Parameters
Type Name Description
FormattedText text
PdfPoint point

DrawTextLines(IReadOnlyList<FormattedTextLine>, PdfPoint, double, TextAlignment)

Draws explicitly laid-out text lines at the given bottom-left origin. The caller supplies line breaks and segment widths; this method does not wrap text.

Declaration
public void DrawTextLines(IReadOnlyList<FormattedTextLine> lines, PdfPoint point, double maxTextWidth = 0, TextAlignment alignment = TextAlignment.Left)
Parameters
Type Name Description
IReadOnlyList<FormattedTextLine> lines

The visual lines to emit.

PdfPoint point

The bottom-left origin of the text block.

double maxTextWidth

The alignment column width, or 0 for line-width alignment.

TextAlignment alignment

The horizontal alignment within the column.

EndLayer()

End the current optional-content group section.

Declaration
public void EndLayer()

GetText()

Returns the concatenated text currently present on the page, including text drawing operations that have not yet been serialized.

Declaration
public string GetText()
Returns
Type Description
string

The page text separated into visual lines.

RecognizeTables(TableRecognitionOptions?)

Recognizes table-like text layouts from the page's interpreted content stream. The detection is heuristic and intended for extraction scenarios (for example exporting tabular data to spreadsheet formats).

Declaration
public IReadOnlyList<DetectedTable> RecognizeTables(TableRecognitionOptions? options = null)
Parameters
Type Name Description
TableRecognitionOptions options
Returns
Type Description
IReadOnlyList<DetectedTable>

RemoveAllText()

Removes queued text drawing operations from this page content. Returns the number of removed text operations.

Declaration
public int RemoveAllText()
Returns
Type Description
int

RemoveGraphicsObjects()

Removes vector graphics drawing operations queued on this page content. Returns the number of removed operations.

Declaration
public int RemoveGraphicsObjects()
Returns
Type Description
int

RemoveImages()

Removes queued image drawing operations from this page content. Returns the number of removed image operations.

Declaration
public int RemoveImages()
Returns
Type Description
int

ReplaceFontFamily(string, string, bool)

Replaces queued text segment font family names. Returns the number of changed segments.

Declaration
public int ReplaceFontFamily(string oldFontFamily, string newFontFamily, bool ignoreCase = true)
Parameters
Type Name Description
string oldFontFamily
string newFontFamily
bool ignoreCase
Returns
Type Description
int

ReplaceText(string, string, bool, int)

Replaces occurrences of oldValue in queued text drawing operations. Returns the number of replacements performed.

Declaration
public int ReplaceText(string oldValue, string newValue, bool ignoreCase = false, int maxReplacements = 2147483647)
Parameters
Type Name Description
string oldValue
string newValue
bool ignoreCase
int maxReplacements
Returns
Type Description
int

ReplaceTextInStream(string, string, bool)

Replaces occurrences of oldValue with newValue in the page's existing content stream (text shown via Tj, TJ, ', " operators). Returns the number of replacements performed. This operates on the already-saved content stream, not on queued drawing operations.

Declaration
public int ReplaceTextInStream(string oldValue, string newValue, bool ignoreCase = false)
Parameters
Type Name Description
string oldValue
string newValue
bool ignoreCase
Returns
Type Description
int

ReplaceTextRegex(string, string, bool)

Replaces regular expression matches in queued text drawing operations. Returns the number of replacements performed.

Declaration
public int ReplaceTextRegex(string pattern, string replacement, bool ignoreCase = false)
Parameters
Type Name Description
string pattern
string replacement
bool ignoreCase
Returns
Type Description
int

ReplaceTextRegexInStream(string, string, bool)

Replaces regular expression matches in the page's existing content stream. Returns the number of replacements performed.

Declaration
public int ReplaceTextRegexInStream(string pattern, string replacement, bool ignoreCase = false)
Parameters
Type Name Description
string pattern
string replacement
bool ignoreCase
Returns
Type Description
int

ToString()

Returns the concatenated text of all TextContent elements on the page, separated by spaces.

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX