AnnPDFConvertor Class
Summary
Defines a class that converts between AnnObject annotation objects and PDFAnnotation annotation objects.
Syntax
public static class AnnPDFConvertor
Public MustInherit NotInheritable Class AnnPDFConvertor
public sealed static class AnnPDFConvertor
function Leadtools.Annotations.Documents.AnnPDFConvertor()
Example
This example demonstrates how to convert from AnnObject objects to PDFAnnotation objects and vice versa.
Imports Leadtools
Imports Leadtools.Annotations.Core
Imports Leadtools.Annotations.Documents
Imports Leadtools.Pdf
<TestMethod()> _
Public Sub AnnPDFConvertor_AnnPDFConvertor()
'Create some annotation objects and add it to container
Dim rectangle As AnnRectangleObject = New AnnRectangleObject()
Dim text As AnnTextObject = New AnnTextObject()
'Create new container and annotation object to it
Dim container As AnnContainer = New AnnContainer()
container.Children.Add(rectangle)
container.Children.Add(text)
'Create list of PDFAnnotation as target of our conversion
Dim pdfAnnotations As List(Of PDFAnnotation) = New List(Of PDFAnnotation)()
'Convert fro core annotation object to PDF annotation objects
AnnPDFConvertor.ConvertToPDF(container, pdfAnnotations, 800)
'Print the count of converted objects
Debug.WriteLine(pdfAnnotations.Count) ' the result will be "2"
'Now convert from PDF annotation objects to our core annotation objects
Dim newContainer As AnnContainer = New AnnContainer()
'Assume the size of pdf page that we want to add anotations to is 600*800
AnnPDFConvertor.ConvertFromPDF(pdfAnnotations, newContainer, LeadSizeD.Create(600, 800))
'Print the count of converted objects
Debug.WriteLine(newContainer.Children.Count) ' the result will be "2"
End Sub
using Leadtools.Annotations.Core;
using Leadtools.Annotations.Documents;
using Leadtools.Pdf;
public void AnnPDFConvertor_AnnPDFConvertor()
{
//Create some annotation objects and add it to container
AnnRectangleObject rectangle = new AnnRectangleObject();
AnnTextObject text = new AnnTextObject();
//Create new container and annotation object to it
AnnContainer container = new AnnContainer();
container.Children.Add(rectangle);
container.Children.Add(text);
//Create list of PDFAnnotation as target of our conversion
List<PDFAnnotation> pdfAnnotations = new List<PDFAnnotation>();
//Convert fro core annotation object to PDF annotation objects
AnnPDFConvertor.ConvertToPDF(container, pdfAnnotations, 800);
//Print the count of converted objects
Debug.WriteLine(pdfAnnotations.Count); // the result will be "2"
//Now convert from PDF annotation objects to our core annotation objects
AnnContainer newContainer = new AnnContainer();
//Assume the size of pdf page that we want to add anotations to is 600*800
AnnPDFConvertor.ConvertFromPDF(pdfAnnotations, newContainer, LeadSizeD.Create(600, 800));
//Print the count of converted objects
Debug.WriteLine(newContainer.Children.Count); // the result will be "2"
}