Xamarin.Android

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfGraphicsState

    Show / Hide Table of Contents

    Class PdfGraphicsState

    Represents the state of a Graphics object. This object is returned by a call to the Save methods.

    Inheritance
    System.Object
    PdfGraphicsState
    Namespace: Syncfusion.Pdf.Graphics
    Assembly: Syncfusion.Pdf.Portable.dll
    Syntax
    public class PdfGraphicsState : Object
    Examples
    // Create a PDF Document.
    PdfDocument doc = new PdfDocument();
    //Add pages to the document
    PdfPage page = doc.Pages.Add();
    //Create PDF graphics for the page
    PdfGraphics graphics = page.Graphics;
    //Create PDF font.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
    //Save the graphics.
    PdfGraphicsState state = graphics.Save();
    //Set graphics translate transform.
    graphics.TranslateTransform(100, 100);            
    //Draws the String.
    graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0);
    //Restore the graphics.
    graphics.Restore(state);
    //Save the document
    doc.Save("Output.pdf");
    //Close the document
    doc.Close(true);
    ' Create a PDF Document.
    Dim doc As New PdfDocument()
    'Add pages to the document
    Dim page As PdfPage = doc.Pages.Add()
    'Create PDF graphics for the page
    Dim graphics As PdfGraphics = page.Graphics
    'Create PDF font.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
    'Save the graphics.
    Dim state As PdfGraphicsState = graphics.Save()
    'Set graphics translate transform.
    graphics.TranslateTransform(100, 100)
    'Draws the String.
    graphics.DrawString("Hello world!", font, PdfPens.Red, 0, 0)
    'Restore the graphics.
    graphics.Restore(state)
    'Save the document
    doc.Save("Output.pdf")
    'Close the document
    doc.Close(True)
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved