This sample shows how to load an existing PDF document using PdfDocument.Open method.
Note, that Open method replaces the contents of PDF document with contents of the loaded document.
You can also load an existing PDF document by passing a path to a PDF file and, optionally, password as parameters to PdfDocument class constructor.
using System.Diagnostics; namespace BitMiracle.Docotic.Pdf.Samples { public static class OpenDocument { public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. PdfDocument pdf = new PdfDocument(); pdf.Open("Sample data/jfif3.pdf"); PdfPage page = pdf.Pages[0]; page.Canvas.DrawString(10, 80, "This text added by Docotic.Pdf Sample Browser"); string pathToFile = "OpenDocument.pdf"; pdf.Save(pathToFile); pdf.Dispose(); Process.Start(pathToFile); } } }
Imports System.Diagnostics Imports BitMiracle.Docotic.Pdf Namespace BitMiracle.Docotic.Pdf.Samples Public NotInheritable Class OpenDocument Public Shared Sub Main() ' NOTE: ' When used in trial mode, the library imposes some restrictions. ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx ' for more information. Dim pdf As New PdfDocument() pdf.Open("Sample data/jfif3.pdf") Dim page As PdfPage = pdf.Pages(0) page.Canvas.DrawString(10, 80, "This text added by Docotic.Pdf Sample Browser") Dim pathToFile As String = "OpenDocument.pdf" pdf.Save(pathToFile) pdf.Dispose() Process.Start(pathToFile) End Sub End Class End Namespace
