Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, September 14, 2018 10:44:57 AM(UTC)
Anthony Northrup

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#annotation

Code:
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.
File Attachment(s):
CS_SaveAnnotationsAsPdf20.zip (4kb) downloaded 244 time(s).
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.048 seconds.