menu

UWP

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfPageBase - UWP API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfPageBase

    The abstract base class for all pages, Provides methods and properties to create PDF pages and its elements

    Inheritance
    System.Object
    PdfPageBase
    PdfLoadedPage
    PdfPage
    Implements
    IPdfWrapper
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.UWP.dll
    Syntax
    public abstract class PdfPageBase : Object, IPdfWrapper

    Properties

    Annotations

    Gets the collection of the page's annotations (Read only).

    Declaration
    public PdfLoadedAnnotationCollection Annotations { get; }
    Property Value
    Type Description
    PdfLoadedAnnotationCollection

    The PdfLoadedAnnotationCollection that represents the page's annotations

    Examples
    //Load the document
    PdfLoadedDocument lDoc = new PdfLoadedDocument("inputAnnotation.pdf");
    //get the first page from the document
    PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage;
    //Get the annotation collection
    PdfLoadedAnnotationCollection annotations = page.Annotations;
    //Save the document
    lDoc.Save("sample.pdf");
    lDoc.Close(true);
    'Load the document
    Dim lDoc As New PdfLoadedDocument("inputAnnotation.pdf")
    'Get the first page from the document
    Dim page As PdfLoadedPage = TryCast(lDoc.Pages(0), PdfLoadedPage)
    'Get the annotation collections
    Dim annotations As PdfLoadedAnnotationCollection = page.Annotations
    'Save the document
    lDoc.Save("sample.pdf")
    lDoc.Close(True)
    See Also
    PdfLoadedDocument
    PdfLoadedPage

    DefaultLayer

    Gets the default layer of the page (Read only).

    Declaration
    public PdfPageLayer DefaultLayer { get; }
    Property Value
    Type Description
    PdfPageLayer

    The PdfPageLayer of the Page

    Examples
    //Create new document.
    PdfDocument document = new PdfDocument();
    //Set page size.
    document.PageSettings = new PdfPageSettings(new SizeF(350, 300));
    //Add new page.
    PdfPage page = document.Pages.Add();
    //Create new instance for PDF font.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16);
    //Draw the text.
    page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, new PointF(150, 10));
    //Add the first layer
    page.Layers.Add();
    //Get default layer graphics.
    PdfGraphics graphics = page.DefaultLayer.Graphics;
    graphics.TranslateTransform(100, 60);
    //Create new instance for PDF pen.
    PdfPen pen = new PdfPen(Color.Red, 50);
    RectangleF rect = new RectangleF(0, 0, 50, 50);
    //Draw arc.
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Blue, 30);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    pen = new PdfPen(Color.Yellow, 20);
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Green, 10);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    //Add another layer on the page
    page.Layers.Add();
    //Increment the layer
    page.DefaultLayerIndex += 1;
    graphics = page.DefaultLayer.Graphics;
    graphics.TranslateTransform(100, 180);
    graphics.SkewTransform(0, 50);
    //Draw another set of elements
    pen = new PdfPen(Color.Red, 50);
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Blue, 30);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    pen = new PdfPen(Color.Yellow, 20);
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Green, 10);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    //Save the pdf document.
    document.Save("Layer.pdf");
    //Close the document.
    document.Close(true);
    'Create new document.
    Dim document As PdfDocument = New PdfDocument()
    'Set page size.
    document.PageSettings = New PdfPageSettings(New SizeF(350, 300))
    'Add new page.
    Dim page As PdfPage = document.Pages.Add()
    'Create new instance for PDF font.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 16)
    'Draw the text.
    page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, New PointF(150, 10))
    'Add the first layer
    page.Layers.Add()
    'Get default layer graphics.
    Dim graphics As PdfGraphics = page.DefaultLayer.Graphics
    graphics.TranslateTransform(100, 60)
    'Create new instance for PDF pen.
    Dim pen As PdfPen = New PdfPen(Color.Red, 50)
    Dim rect As RectangleF = New RectangleF(0, 0, 50, 50)
    'Draw arc.
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Blue, 30)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    pen = New PdfPen(Color.Yellow, 20)
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Green, 10)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    'Add another layer on the page
    page.Layers.Add()
    'Increment the layer
    page.DefaultLayerIndex += 1
    graphics = page.DefaultLayer.Graphics
    graphics.TranslateTransform(100, 180)
    graphics.SkewTransform(0, 50)
    'Draw another set of elements
    pen = New PdfPen(Color.Red, 50)
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Blue, 30)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    pen = New PdfPen(Color.Yellow, 20)
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Green, 10)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    'Save and close the document.
    document.Save("Layer.pdf")
    document.Close(True)
    See Also
    PdfDocument
    PdfPage
    PdfPageLayer

    DefaultLayerIndex

    Gets or sets index of the default layer.

    Declaration
    public int DefaultLayerIndex { get; set; }
    Property Value
    Type
    System.Int32
    Examples
    //Create new document.
    PdfDocument document = new PdfDocument();
    //Set page size.
    document.PageSettings = new PdfPageSettings(new SizeF(350, 300));
    //Add new page.
    PdfPage page = document.Pages.Add();
    //Create new instance for PDF font.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16);
    //Draw the text.
    page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, new PointF(150, 10));
    //Add the first layer
    page.Layers.Add();
    //Get default layer graphics.
    PdfGraphics graphics = page.DefaultLayer.Graphics;
    graphics.TranslateTransform(100, 60);
    //Create new instance for PDF pen.
    PdfPen pen = new PdfPen(Color.Red, 50);
    RectangleF rect = new RectangleF(0, 0, 50, 50);
    //Draw arc.
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Blue, 30);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    pen = new PdfPen(Color.Yellow, 20);
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Green, 10);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    //Add another layer on the page
    page.Layers.Add();
    //Increment the layer
    page.DefaultLayerIndex += 1;
    graphics = page.DefaultLayer.Graphics;
    graphics.TranslateTransform(100, 180);
    graphics.SkewTransform(0, 50);
    //Draw another set of elements
    pen = new PdfPen(Color.Red, 50);
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Blue, 30);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    pen = new PdfPen(Color.Yellow, 20);
    graphics.DrawArc(pen, rect, 360, 360);
    pen = new PdfPen(Color.Green, 10);
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360);
    //Save the pdf document.
    document.Save("Layer.pdf");
    //Close the document.
    document.Close(true);
    'Create new document.
    Dim document As PdfDocument = New PdfDocument()
    'Set page size.
    document.PageSettings = New PdfPageSettings(New SizeF(350, 300))
    'Add new page.
    Dim page As PdfPage = document.Pages.Add()
    'Create new instance for PDF font.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 16)
    'Draw the text.
    page.Graphics.DrawString("Layers", font, PdfBrushes.DarkBlue, New PointF(150, 10))
    'Add the first layer
    page.Layers.Add()
    'Get default layer graphics.
    Dim graphics As PdfGraphics = page.DefaultLayer.Graphics
    graphics.TranslateTransform(100, 60)
    'Create new instance for PDF pen.
    Dim pen As PdfPen = New PdfPen(Color.Red, 50)
    Dim rect As RectangleF = New RectangleF(0, 0, 50, 50)
    'Draw arc.
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Blue, 30)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    pen = New PdfPen(Color.Yellow, 20)
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Green, 10)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    'Add another layer on the page
    page.Layers.Add()
    'Increment the layer
    page.DefaultLayerIndex += 1
    graphics = page.DefaultLayer.Graphics
    graphics.TranslateTransform(100, 180)
    graphics.SkewTransform(0, 50)
    'Draw another set of elements
    pen = New PdfPen(Color.Red, 50)
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Blue, 30)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    pen = New PdfPen(Color.Yellow, 20)
    graphics.DrawArc(pen, rect, 360, 360)
    pen = New PdfPen(Color.Green, 10)
    graphics.DrawArc(pen, 0, 0, 50, 50, 360, 360)
    'Save and close the document.
    document.Save("Layer.pdf")
    document.Close(True)
    See Also
    PdfDocument
    PdfPage
    PdfPageLayer

    Dictionary

    Gets the page dictionary.

    Declaration
    public PdfDictionary Dictionary { get; }
    Property Value
    Type
    PdfDictionary

    FormFieldsTabOrder

    Gets or sets the tab order type for form fields

    Declaration
    public PdfFormFieldsTabOrder FormFieldsTabOrder { get; set; }
    Property Value
    Type
    PdfFormFieldsTabOrder
    Examples
    //Create a new document.
    PdfDocument document = new PdfDocument();
    //Create a new page.
    PdfPage page = document.Pages.Add();
    //Set form fields tab order.
    page.FormFieldsTabOrder = PdfFormFieldsTabOrder.Manual;
    //Create new text box field.
    PdfTextBoxField field = new PdfTextBoxField(page, "Hello");
    //Set field tab index as 3.
    field.TabIndex = 3;
    //Set field bounds.
    field.Bounds = new RectangleF(0, 0, 100, 30);
    //Create new text box field.
    PdfTextBoxField field1 = new PdfTextBoxField(page, "Hello1");
    //Set field tab index as 2.
    field.TabIndex = 2;
    //Set field bounds.
    field1.Bounds = new RectangleF(200, 0, 100, 30);
    //Create new text box field.
    PdfTextBoxField field2 = new PdfTextBoxField(page, "Hello2");
    //Set field tab index as 1.
    field.TabIndex = 1;
    //Set field bounds.
    field2.Bounds = new RectangleF(0, 50, 100, 30);
    //Create new text box field.
    PdfTextBoxField field3 = new PdfTextBoxField(page, "Hello3");
    //Set field tab index as 0.
    field.TabIndex = 0;
    //Set field bounds.
    field3.Bounds = new RectangleF(200, 50, 100, 30);
    //Adds the form field to the document. 
    document.Form.Fields.Add(field);
    document.Form.Fields.Add(field1);
    document.Form.Fields.Add(field2);
    document.Form.Fields.Add(field3);
    //Save the pdf document.
    document.Save("TabOrder.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As PdfDocument = New PdfDocument()
    'Creates a new page.
    Dim page As PdfPage = document.Pages.Add()
    'Set form fields tab order.
    page.FormFieldsTabOrder = PdfFormFieldsTabOrder.Manual
    'Create new text box field.
    Dim field As PdfTextBoxField = New PdfTextBoxField(page, "Hello")
    'Set field tab index as 3.
    field.TabIndex = 3
    'Set field bounds.
    field.Bounds = New RectangleF(0, 0, 100, 30)
    'Create new text box field.
    Dim field1 As PdfTextBoxField = New PdfTextBoxField(page, "Hello1")
    'Set field tab index as 2.
    field.TabIndex = 2
    'Set field bounds.
    field1.Bounds = New RectangleF(200, 0, 100, 30)
    'Create new text box field.
    Dim field2 As PdfTextBoxField = New PdfTextBoxField(page, "Hello2")
    'Set field tab index as 1.
    field.TabIndex = 1
    'Set field bounds.
    field2.Bounds = New RectangleF(0, 50, 100, 30)
    'Create new text box field.
    Dim field3 As PdfTextBoxField = New PdfTextBoxField(page, "Hello3")
    'Set field tab index as 0.
    field.TabIndex = 0
    'Set field bounds.
    field3.Bounds = New RectangleF(200, 50, 100, 30)
    'Adds the form field to the document. 
    document.Form.Fields.Add(field)
    document.Form.Fields.Add(field1)
    document.Form.Fields.Add(field2)
    document.Form.Fields.Add(field3)
    'Save document to disk.
    document.Save("TabOrder.pdf")
    'Close the document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage
    Syncfusion.Pdf.Interactive

    Graphics

    Gets the graphics of the DefaultLayer.

    Declaration
    public PdfGraphics Graphics { get; }
    Property Value
    Type Description
    PdfGraphics

    The PdfGraphics that represents a graphics of the page.

    Examples
     //Create a PDF document
     PdfDocument document = new PdfDocument();
     //Create a PDF page
     PdfPage page = document.Pages.Add();
     //Get graphics
     PdfGraphics graphics = page.Graphics;
     //Draw a rectangle
     graphics.DrawRectangle(PdfBrushes.Red, new RectangleF(0, 0, 100, 200));
     //Save and close the document
     document.Save("output.pdf");
     document.Close(true);
    'Create a PDF document
    Dim document As New PdfDocument()
    'Create a PDF page
    Dim page As PdfPage = document.Pages.Add()
    'Get graphics
    Dim graphics As PdfGraphics = page.Graphics
    'Draw a rectangle
    graphics.DrawRectangle(PdfBrushes.Red, New RectangleF(0, 0, 100, 200))
    'Save and close the document
    document.Save("output.pdf")
    document.Close(True)
    See Also
    PdfDocument
    PdfPage
    PdfGraphics

    IsBlank

    Gets the PdfLoadedPage is blank or not;Default value is false

    Declaration
    public bool IsBlank { get; }
    Property Value
    Type
    System.Boolean
    Examples
    //load the existing pdf document
    PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
    //set the bool value
    bool value = true;
    //load first page
    bool page = loadedDocument.Pages[0].IsBlank;
    //return the bool value of IsBlank property
    page.Equals(value);
    //close the loaded document
    loadedDocument.Close(true)
    'load the existing pdf document.
    Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
    'set the bool value
    Dim value As Boolean = True
    'load first page.
    Dim page As Boolean = loadedDocument.Pages(0).IsBlank
    'return the bool value of IsBlank property.
    page.Equals(value)
    'close the loaded document.
    loadedDocument.Close(True)

    Layers

    Gets the collection of the page's layers (Read only).

    Declaration
    public PdfPageLayerCollection Layers { get; }
    Property Value
    Type Description
    PdfPageLayerCollection

    The PdfPageLayerCollection that represents the page's layers

    Examples
    //Create a PDF document
    PdfDocument document = new PdfDocument();
    //Add page to the document
    PdfPage page=document.Pages.Add();
    //Get the page layer
    PdfPageLayerCollection angle = page.Layers;
    //Save and close the PDF document
    document.Save("output.Pdf");
    document.Close(true);
    'Create a PDF document
    Dim document As New PdfDocument()
    'Add page to the document
    Dim page As PdfPage = document.Pages.Add()
    'Get the page layer
    Dim angle As PdfPageLayerCollection = page.Layers
    'Save and close the PDF document
    document.Save("output.Pdf")
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    Rotation

    Gets or sets the PDF page rotation.

    Declaration
    public PdfPageRotateAngle Rotation { get; set; }
    Property Value
    Type Description
    PdfPageRotateAngle

    The PdfPageRotateAngle that represents the page rotation

    Examples
     //Create a PDF document
     PdfDocument document = new PdfDocument();
     //Create a page
     PdfPage page = new PdfPage();
     //Insert page in the document
     document.Pages.Insert(0, page);
     //Get rotation
     PdfPageRotateAngle angle = page.Rotation;
     //Save and close the PDF document
     document.Save("output.Pdf");
     document.Close(true);
    'Create a PDF document
    Dim document As New PdfDocument()
    'Create a page
    Dim page As New PdfPage()
    'Insert page in the document
    document.Pages.Insert(0, page)
    'Get rotation
    Dim angle As PdfPageRotateAngle = page.Rotation
    'Save and close the PDF document
    document.Save("output.Pdf")
    document.Close(True)

    Size

    Gets the size of the page (Read only).

    Declaration
    public abstract SizeF Size { get; }
    Property Value
    Type
    System.Drawing.SizeF
    Examples
    //Load an existing document.
    PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
    //Get size of first page
    SizeF size = ldoc.Pages[0].Size;
    //Save and close the document.
    ldoc.Save("Output.pdf");
    ldoc.Close(true);
    'Load an existing document.
    Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
    'Get size of first page
    Dim size As SizeF = ldoc.Pages(0).Size
    'Save and close the document.
    ldoc.Save("Output.pdf")
    ldoc.Close(True)
    See Also
    PdfLoadedDocument

    Methods

    CreateTemplate()

    Creates a template from page content and all annotation appearances.

    Declaration
    public PdfTemplate CreateTemplate()
    Returns
    Type Description
    PdfTemplate

    The created PdfTemplate.

    Examples
     //Load an existing PDF.
     PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);     
     //Load the page
     PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
     //Create the template from the page.
     PdfTemplate template = loadedPage.CreateTemplate();
     //Create a new PDF document
     PdfDocument document = new PdfDocument();
     //Set the document margin
     document.PageSettings.SetMargins(2);
     //Add the page
     PdfPage page = document.Pages.Add();
     //Create the graphics
     PdfGraphics graphics = page.Graphics;
     //Draw the template
     graphics.DrawPdfTemplate(template, PointF.Empty,new SizeF(page.Size.Width/2,page.Size.Height));
     //Save the new document.
     document.Save("output.pdf");
     //Close the documents
    loadedDocument.Close(true);
    document.Close(true);
    'Load the existing PDF document.
    Dim loadedDocument As New PdfLoadedDocument(fileName)
    'Load the page
    Dim loadedPage As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage)
    'Create the template from the page.
    Dim template As PdfTemplate = loadedPage.CreateTemplate()
    'Create a new PDF document
    Dim document As New PdfDocument()
    'Set the document margin
    document.PageSettings.SetMargins(2)
    'Add the page
    Dim page As PdfPage = document.Pages.Add()
    'Create the graphics
    Dim graphics As PdfGraphics = page.Graphics
    'Draw the template
    graphics.DrawPdfTemplate(template, PointF.Empty, New SizeF(page.Size.Width \ 2, page.Size.Height))
    'Save the new document.
    document.Save("output.pdf")
    'Close the documents
    loadedDocument.Close(True)

    ExtractText()

    Extracts text from the given PDF Page.

    Declaration
    public string ExtractText()
    Returns
    Type Description
    System.String

    The Extracted Text.

    ExtractText(Boolean)

    Extracting the Text from the given PDF Page.

    Declaration
    public string ExtractText(bool IsLayout)
    Parameters
    Type Name Description
    System.Boolean IsLayout

    Performs layout based text extraction if it is true.

    Returns
    Type Description
    System.String

    The Extracted Text.

    GetAnnotations()

    Gets the annotations array.

    Declaration
    public PdfArray GetAnnotations()
    Returns
    Type Description
    PdfArray

    The array of the annotations.

    GetAnnots()

    Gets the annotations array.

    Declaration
    public PdfArray GetAnnots()
    Returns
    Type Description
    PdfArray

    The array of the annotations.

    GetResources()

    Gets the resources and modifies the page dictionary.

    Declaration
    public virtual PdfResources GetResources()
    Returns
    Type Description
    PdfResources

    Pdf resources.

    Explicit Interface Implementations

    IPdfWrapper.Element

    Gets the wrapped element.

    Declaration
    IPdfPrimitive IPdfWrapper.Element { get; }
    Returns
    Type
    IPdfPrimitive

    Implements

    IPdfWrapper

    Extension Methods

    DateTimeExtension.ToDateTime(Object)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved