Home Features Download Tutorial Version History License PDF Mosaic Blog Source Code
This sample shows how to save and restore graphics state using PDFCanvas.SaveGraphicsState and PdfCanvas.RestoreGraphicsState methods.
C# :
using PDFMosaic; using System.Drawing; using System; namespace GraphicsState { class GraphicssState { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); PDFCanvas canvas = document.Pages[0].Canvas; canvas.SaveGraphicsState(); PDFPath path = new PDFPath(); path.AddCircle(100, 100, 50); canvas.SetClip(path); canvas.DrawRectangle(new PDFSolidBrush(new PDFColorRGB(0, 255, 0)), 50, 50, 50, 50); canvas.RestoreGraphicsState(); canvas.DrawRectangle(new PDFSolidBrush(new PDFColorRGB(255, 0, 0)), 100, 50, 50, 50); document.Save(“GraphicsState.pdf”, true); } } }
Visial Basic.NET :
Imports PDFMosaic Imports System.Drawing Imports System Module GraphicsState Sub Main() Dim document As PDFDocument = New PDFDocument() document.Pages.Add(New PDFPage(PDFPaperFormat.A4)) Dim canvas As PDFCanvas = document.Pages(0).Canvas canvas.SaveGraphicsState() Dim path As PDFPath = New PDFPath() path.AddCircle(100, 100, 50) canvas.SetClip(path) canvas.DrawRectangle(New PDFSolidBrush(New PDFColorRGB(0, 255, 0)), 50, 50, 50, 50) canvas.RestoreGraphicsState() canvas.DrawRectangle(New PDFSolidBrush(New PDFColorRGB(255, 0, 0)), 100, 50, 50, 50) document.Save(“GraphicsState.pdf”, True) End Sub End Module
Home Features Download Tutorial Version History License PDF Mosaic Blog Source Code