But like every difficult thing in the world, this little problem comes with a solution.
Save ( dataDir + "GetResourceOfAnnotation_Out.With PDF increasingly becoming the ultimate form of document sharing, it is not unusual for a person to wonder how to annotate a PDF?Īt one point or the other, you have wanted to make edits and annotations on your digital document, just like you do on a physical book – but in vain.Īs simple as making an edit to the document may sound, it is actually a pretty complicated feat for PDF files. Pages, new Rectangle ( 100, 400, 300, 600 ), dataDir + "AddSwfFileAsAnnotation.swf" ) doc. ScreenAnnotation sa = new ScreenAnnotation ( doc.
The following code snippet shows how to get a particular annotation and its properties.ĭocument doc = new Document ( dataDir + "AddAnnotation.pdf" ) //Create annotation This returns an Annotation object which needs to be cast to a particular annotation type, for example TextAnnotation. To get a particular annotation, specify its index. Get Particular Annotation from PDF FileĪnnotations are associated with individual pages and stored in a Page object’s AnnotationCOllection collection. You can get each annotation of the collection in a base annotation type called MarkupAnnotation Class and then show its properties. Please note that to get all annotations from the whole PDF, you have to loop through the document’s PageCollection Class collection before navigating through the AnnotationCollection class collection. Using using System using System.Linq namespace The following code snippet shows you how to add Popup Annotation in a PDF page using an example of adding a parent’s Line annotation. It shall have no appearance stream or associated actions of its own and shall be identified by the Popup entry in the parent’s annotation dictionary. It shall not appear alone but is associated with a markup annotation, its parent annotation, and shall be used for editing the parent’s text. Save ( dataDir ) How to add Popup AnnotationĪ Pop-up Annotation displays text in a pop-up window for entry and editing. Add ( textAnnotation ) dataDir = dataDir + "AddAnnotation_out.pdf" // Save output file Rectangle ( 200, 400, 400, 600 ) // Add annotation in the annotations collection of the page Dash = new Dash ( 1, 1 ) textAnnotation. Key Border border = new Border ( textAnnotation ) border. Contents = "Sample contents for the annotation" textAnnotation. Subject = "Sample Subject" textAnnotation. Title = "Sample Annotation Title" textAnnotation. TextAnnotation textAnnotation = new TextAnnotation ( pdfDocument. GetDataDir_AsposePdf_Annotations () // Open documentĭocument pdfDocument = new Document ( dataDir + "AddAnnotation.pdf" ) // Create annotation For complete examples and data files, please go to The following code snippet shows you how to add an annotation in a PDF page.