// // Copyright (c) 2001-2012 by PDFTron Systems Inc. All Rights Reserved. // using pdftron; using pdftron.Common; using pdftron.Filters; using pdftron.SDF; using pdftron.PDF; namespace AnnotationTestCS { /// /// Summary description for Class1. /// class Class1 { static void AnnotationHighLevelAPI(PDFDoc doc) { // The following code snippet traverses all annotations in the document System.Console.WriteLine("Traversing all annotations in the document..."); PageIterator itr = doc.GetPageIterator(); for (; itr.HasNext(); itr.Next()) { System.Console.WriteLine("Page {0:d}: ", itr.GetPageNumber()); Page page = itr.Current(); int num_annots = page.GetNumAnnots(); for (int i=0; i /// The main entry point for the application. /// [System.STAThread] static void Main(string[] args) { PDFNet.Initialize(); try { System.Console.WriteLine("-------------------------------------------------"); System.Console.WriteLine("Opening the input file..."); PDFDoc doc = new PDFDoc(input_path + "numbered.pdf"); doc.InitSecurityHandler(); // An example of using SDF/Cos API to add any type of annotations. AnnotationLowLevelAPI(doc); doc.Save(output_path + "annotation_test1.pdf", SDFDoc.SaveOptions.e_linearized); System.Console.WriteLine("Done. Results saved in annotation_test1.pdf"); // An example of using the high-level PDFNet API to read existing annotations, // to edit existing annotations, and to create new annotation from scratch. AnnotationHighLevelAPI(doc); doc.Save(output_path + "annotation_test2.pdf", SDFDoc.SaveOptions.e_linearized); System.Console.WriteLine("Done. Results saved in annotation_test2.pdf"); doc.Close(); } catch (PDFNetException e) { System.Console.WriteLine(e.Message); } PDFNet.Terminate(); } } }