VB.NET PDF: How to HTML5 PDF Viewer PDF Create PDF Export File & Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF PDF Viewer Work with Other SDKs Barcode Read Barcode Create OCR Twain
Annotation & Drawing
  |  
Home ›› XDoc.PDF ›› VB.NET PDF: Annotation & Drawing

VB.NET PDF - PDF Annotation in VB.NET


Guide to Draw, Add and Edit Various Annotations on PDF File in VB.NET Programming




Annotation Overview



When we are reading or viewing a PDF document file, we may often need to mark the source PDF file by adding some comments, notes, explanations or other remarks. And this VB.NET PDF annotation control add-on, which integrates advanced VB.NET PDF editing functions and VB.NET image annotating features, provides developers with a great .NET solution to annotate .pdf file with both text & graphics. From this page, you will get a simple VB.NET online PDF annotation tutorial.




API Explanations



To help you better understand above VB.NET PDF annotating APIs, we here specifically illustrate some programming classes that may cause unnecessary confusion.


PDFDocument: this VB.NET PDF annotation control component uses PDFDocument class to represent one in-memory PDF document file. A PDFDocument object contains all information about source PDF document file.


PDFPage: As for one page of PDFDocument instance, RasterEdge VB.NET PDF annotator control add-on uses one PDFPage object to display it. Thus, PDFPage, derived from REPage, is a programming abstraction for representing one PDF page.




Annotating Process



Besides giving you the detailed VB.NET PDF annotating APIs, we think it is necessary to briefly introduce the general process of this VB.NET PDF annotation application.


Decode source PDF document file into an in-memory object, namely, PDFDocument, using VB.NET PDF annotation control add-on;


Accurately select the page on which you want to draw annotation using VB.NET code;


Create your annotation object and customize it with desired imaging properties;


Add & burn your annotation on selected PDF page using above mentioned VB.NET PDF annotation APIs;


Save and re-encode target PDF file to desired web or file path.




VB.NET DLLs: PDF Annotation



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Raster.dll


  RasterEdge.XDoc.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;




VB.NET: Retrieve All Annotations Information from PDF Document



This demo code let you learn how to retrieve all annotations from PDF file in VB.NET project.




' Get PDF document.
Dim fileInpath As String = ""
Dim doc As PDFDocument = New PDFDocument(fileInpath)

' Get all annotations.
Dim allAnnotation As List(Of IPDFAnnot) = PDFAnnotHandler.GetAllAnnotations(doc)





VB.NET: Retrieve All Annotations Information from PDF Page



This demo code let you learn how to retrieve all annotations from PDF page in VB.NET project.




' Get PDF document.
Dim fileInpath As String = ""
Dim doc As PDFDocument = New PDFDocument(fileInpath)

' Get PDF page.
Dim page As PDFPage = doc.GetPage(0)

' Get all annotations of PDF page.
Dim allAnnotation As List(Of IPDFAnnot) = PDFAnnotHandler.GetAllAnnotations(page)





VB.NET: Add an Annotation - Sticky Note



Use the code below to add an sticky note annotation to a PDF page in VB.NET project.




Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "Annot_8.pdf"

' open a PDF file
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
' get the 1st page
Dim page As PDFPage = doc.GetPage(0)

' create the annotation
Dim annot As PDFAnnotStickyNote = New PDFAnnotStickyNote()

annot.Position = New PointF(100.0F, 100.0F)

' add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot)

' save to a new file
doc.Save(outputFilePath)