Skip to content
  • PDF Tools
    • Adobe® PDF Library
    • PDF SDKs
      • Adobe PDF Converter
      • Forms Extension
    • Specialized Utilities
      • PDF Checker
      • PDF Optimizer
      • FLIP2PDF
      • Forms Flattener
      • PDF2IMG
      • PDF2PRINT
      • Adobe Experience Reader Extensions
    • Adobe® InDesign Server
  • Developers
    • Support
    • Documentation
    • GitHub
    • Docker
    • NuGet
  • Solutions
    • Flatten Transparencies
    • Merge
    • Text Extraction
    • Watermark
    • Converting PDFs to PDF/A
    • Compression
    • Redactions
    • Extract Images
    • Text Search
  • Resources
    • Articles
  • Pricing
Menu
  • PDF Tools
    • Adobe® PDF Library
    • PDF SDKs
      • Adobe PDF Converter
      • Forms Extension
    • Specialized Utilities
      • PDF Checker
      • PDF Optimizer
      • FLIP2PDF
      • Forms Flattener
      • PDF2IMG
      • PDF2PRINT
      • Adobe Experience Reader Extensions
    • Adobe® InDesign Server
  • Developers
    • Support
    • Documentation
    • GitHub
    • Docker
    • NuGet
  • Solutions
    • Flatten Transparencies
    • Merge
    • Text Extraction
    • Watermark
    • Converting PDFs to PDF/A
    • Compression
    • Redactions
    • Extract Images
    • Text Search
  • Resources
    • Articles
  • Pricing
  • PDF Tools
    • Adobe® PDF Library
    • PDF SDKs
      • Adobe PDF Converter
      • Forms Extension
    • Specialized Utilities
      • PDF Checker
      • PDF Optimizer
      • FLIP2PDF
      • Forms Flattener
      • PDF2IMG
      • PDF2PRINT
      • Adobe Experience Reader Extensions
    • Adobe® InDesign Server
  • Developers
    • Support
    • Documentation
    • GitHub
    • Docker
    • NuGet
  • Solutions
    • Flatten Transparencies
    • Merge
    • Text Extraction
    • Watermark
    • Converting PDFs to PDF/A
    • Compression
    • Redactions
    • Extract Images
    • Text Search
  • Resources
    • Articles
  • Pricing

Exploring PDF Annotations with Sample Code

  • Datalogics Inc
  • December 5, 2022

PDF annotations allow the user to add markup information or associate objects to specific locations on a page.  The largest category – Markup annotations – include Text, Circle, Redact and others that add features to the page.  A subcategory of Text Markup annotations cover Highlight, Underline, Squiggly and StrikeOut annotations used to modify or emphasize text content.  A “Sticky note” is a combination usage of Text and Popup annotations. Annotations can be especially helpful when remotely collaborating with others on PDFs.   

Non-markup annotations typically perform actions or add objects to the PDF.  Link annotations can redirect the user to another location within the document or externally to URLs. Stamps can be used to add images while other annotation types can be used to add sound, video, 3D streams or attachments.  

The Adobe PDF Library Java and .NET interfaces provide several sample programs that show how to write code to automatically add annotations to PDF files. Let’s explore some of these samples and how they can help users with their PDF workflows.  

AnnotationCopyPaste 

This sample demonstrates how to copy and paste the annotations from one PDF file to another PDF file. The program provides two optional input PDF documents. The first is the source of the annotations, and the second is the PDF document that receives these copied annotations. The program also provides a default name and path for the output PDF document. The second input document, Layers.pdf, is saved as the output document Paste-out.pdf. 

You can provide your own file names for these values in the code, or you can enter your own file names as command line parameters.  

The need to copy annotations from one document to another can be seen in shared review workflows where more than one person might need to comment on a document. This functionality can be used to solve the frustrations that can come along with manually copying and pasting the notes from one file to another, which is cumbersome and uses up a lot of time and resources. The ability to automate this functionality can save time and money and simplify your workflow. 

InkAnnotations

This sample creates and adds a new Ink annotation to a PDF document. An Ink annotation is a freeform line, like what you would create with a pen, or with a stylus on a mobile device.  

With ink annotations, you specify the vertices, and the PDF viewer will automatically draw smoothened curves linking them. This means that you do not have to record all the movements of a graphic pen on your PDF viewer.  

LinkAnnotation 

This program creates a PDF file with an embedded hyperlink, which takes the reader to the second page of the document. Sometimes you may want to add links into your PDF to direct viewers to a different portion of the file for easy referencing or to external locations such as a URL or another PDF document. Programmatically modifying Link annotations can reduce manual efforts when the destination reference has changed (e.g. if the destination http address has changed). 

PolygonAnnotations 

This program generates a PDF output file with a polygon shape (a triangle) as an annotation to the file. 

The program defines the vertices for the outlines of the annotation, and the line and fill colors. Polygon annotations can be used where complex polygons are needed, rather than rectangles, to define the shape and location of the object in a more precise way. 

PolyLineAnnotations 

This program generates a PDF output file with a line shape (an angle) as an annotation to the file. The program defines the vertices for the outlines of the annotation, and the line and fill colors.  A PolyLine is very similar to a Polygon annotation except that the first and last vertex need not be connected. 

Learn More about Annotations

If you’re interested in learning more about PDF annotations, our developer site has documentation with more information on using annotations with APDFL.

  • Tags: Adobe PDF Library

Share this post with your friends

Latest Updates from Datalogics

PDF Tips

How PDF Forms with Barcodes Improve Efficiency in Education Fields

Read More »
September 10, 2022
Adobe PDF Library

Powerful PDF Searching with DocTextFinder in APDFL

Read More »
August 31, 2022
Company News

Results Prove PDF Optimizer Maximizes Compression and Downsizes Competition

Read More »
July 28, 2022
PDF Solutions

Maximum PDF Compression with Minimal Effort

Read More »
August 20, 2022
Load More

PDF SDKs

  • Adobe PDF Library
  • GitHub
  • PDF Converter
  • Forms Extension
  • callas Tools
  • Adobe PDF Print Engine
  • Java Toolkit

Specialized Utilities

  • PDF Optimizer
  • PDF Checker
  • FLIP2PDF
  • PDF2IMG
  • Docker
  • PDF2PRINT
  • PDF Forms Flattener
  • Adobe Experience Reader Extensions

inDesign Server

Developers

  • Contact Support
  • Documentation
  • GitHub
  • Docker
  • NuGet

Solutions

  • Compress PDF Files
  • Converting PDFs to PDF/A
  • Flatten Transparencies
  • Merge PDFs
  • Redaction in PDFs
  • Text Extraction in PDFs
  • Text Search PDF
  • Extract Images from PDFs
  • Watermark PDFs

Resources

  • Education & Articles

Pricing & Licensing

Company

  • About Us
  • EULA
  • Terms & Conditions
  • Privacy Policy
  • Cookie Policy

Contact Us

Contact Support for:

  • Adobe Content Server
  • Adobe Reader Mobile SDK
  • DL Composer
  • PDF Alchemist
Linkedin Twitter Facebook-f Youtube Github