LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Convert LEADTOOLS' AnnObjects to PDF Annotations
#1
Posted
:
Friday, September 14, 2018 10:44:57 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 199
Was thanked: 28 time(s) in 28 post(s)
The LEADTOOLS v20 SDK supports both importing from and exporting to PDF annotations. For more information about this support, refer to the following page:
https://www.leadtools.com/sdk/pdf#annotationCode:The main method used for conversion is the
AnnPDFConvertor.ConvertToPDF method. Here is a complete sample function for adding a list of AnnContainers to a PDF:
Code:
static void LEADToPDF(IEnumerable<AnnContainer> containers, string pdfFile)
{
// Load the information about the PDF file
PDFFile file = new PDFFile(pdfFile);
file.Load();
// Convert all annotations
List<PDFAnnotation> fileAnnotations = new List<PDFAnnotation>();
int page = 1;
foreach (AnnContainer container in containers)
{
// Convert the page annotations
List<PDFAnnotation> pageAnnotations = new List<PDFAnnotation>();
AnnPDFConvertor.ConvertToPDF(container, pageAnnotations, file.Pages[page - 1].Height);
// Set the page number
foreach (PDFAnnotation annotation in pageAnnotations)
annotation.PageNumber = page;
// Add to the total list
fileAnnotations.AddRange(pageAnnotations);
// Increment the page count
page++;
}
// Write the annotations to the file
file.WriteAnnotations(fileAnnotations, pdfFile);
}
Sample Project:This project is from an
old post, but has been updated to the LEADTOOLS v20 SDK using Visual Studio 2017. Note, the new project is now a console application that can be unzipped to any directory. If you do not have the LEADTOOLS SDK installed in "C:\LEADTOOLS 20", simply update the output path inside the project configuration.
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Convert LEADTOOLS' AnnObjects to PDF Annotations
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.