Click or drag to resize

PdfAnnotationDataConverter Class

The PdfAnnotationDataConverter object is capable of taking DotImage Annotation objects and translating them into a format suitable for PDF.
Inheritance Hierarchy
SystemObject
  Atalasoft.dotImage.PdfDoc.Bridge.AnnotatePdfAnnotationDataConverter

Namespace:  Atalasoft.dotImage.PdfDoc.Bridge.Annotate
Assembly:  Atalasoft.dotImage.PdfDoc.Bridge (in Atalasoft.dotImage.PdfDoc.Bridge.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public static class PdfAnnotationDataConverter

The PdfAnnotationDataConverter type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleConvertAnnotationDataToPdf(AnnotationDataCollection, AnnotationUnit, Dpi, PdfDocumentSigner, PdfUnknownAnnotationHandler)
Converts a multiple pages of annotations for PdfDocumentSigner.
Examples
In the following example, annotations are converted for use in the PdfDocumentSigner.
ConvertAnnotationsForPdfDocumentSignerExample
var rectData = new RectangleData()
{
    Size = new SizeF(123, 345),
    Location = new PointF(123, 321),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
var polyData = new PolygonData()
{
    Size = new SizeF(100, 200),
    Location = new PointF(10, 11),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
polyData.Points.AddRange(new[] { new PointF(1, 1), new PointF(50, 50), new PointF(1, 50) });


var collection = new AnnotationDataCollection() { new LayerData() { Items = { rectData, polyData } } };
var dpis = new[] { new Dpi(96, 96, ResolutionUnit.DotsPerInch) };
var signer = new PdfDocumentSigner(pdfStream, null);

var pagesOfAnnots =
    PdfAnnotationDataConverter.ConvertAnnotationDataToPdf(collection, AnnotationUnit.Pixel, dpis,
        signer);

for (var i = 0; i < pagesOfAnnots.Count; i++)
    foreach (var annotation in pagesOfAnnots[i])
        signer.PagesOfAnnotations[i].Add(annotation);

signer.AppendChangesFinal(true);
Public methodStatic memberCode exampleConvertAnnotationDataToPdf(LayerData, AnnotationUnit, Dpi, PdfGeneratedPage, GlobalResources, PdfUnknownAnnotationHandler)
Converts a page of annotations to PDF annotations.
Examples
In the following example, annotations are converted for use in the PdfGeneratedPage.
ConvertAnnotationsForPdfGeneratedPageExample
var rectData = new RectangleData()
{
    Size = new SizeF(123, 345),
    Location = new PointF(123, 321),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
var polyData = new PolygonData()
{
    Size = new SizeF(100, 200),
    Location = new PointF(10, 11),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
polyData.Points.AddRange(new[] { new PointF(1, 1), new PointF(50, 50), new PointF(1, 50) });


var layer = new LayerData() { Items = { rectData, polyData } };
var dpi = new Dpi(96, 96, ResolutionUnit.DotsPerInch);
var doc = new PdfGeneratedDocument(source);
var page = doc.Pages[0] as PdfGeneratedPage;

if (page != null)
{
    var annotations =
        PdfAnnotationDataConverter.ConvertAnnotationDataToPdf(layer, AnnotationUnit.Pixel, dpi, page,
            doc.Resources);
    page.Annotations.AddRange(annotations);
}

doc.Save(pdfStream);
Public methodStatic memberCode exampleConvertAnnotationDataToPdf(LayerData, AnnotationUnit, Dpi, RectangleF, PdfPageRotation, GlobalResources, PdfUnknownAnnotationHandler)
Converts a page of annotations to PDF annotations.
Examples
ConvertAnnotationsToPdfAnnotationsExample
var rectData = new RectangleData()
{
    Size = new SizeF(123, 345),
    Location = new PointF(123, 321),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
var polyData = new PolygonData()
{
    Size = new SizeF(100, 200),
    Location = new PointF(10, 11),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
polyData.Points.AddRange(new[] { new PointF(1, 1), new PointF(50, 50), new PointF(1, 50) });


var layer = new LayerData() { Items = { rectData, polyData } };
var dpi = new Dpi(96, 96, ResolutionUnit.DotsPerInch);
var doc = new PdfGeneratedDocument(source);
var page = doc.Pages[0] as PdfGeneratedPage;

if (page != null)
{
    var cropBox = page.CropBox.IsEmpty() ? page.MediaBox.ToRectangleF() : page.CropBox.ToRectangleF();
    var rotation = page.Rotation;
    var annotations = PdfAnnotationDataConverter.ConvertAnnotationDataToPdf(layer, AnnotationUnit.Pixel,
        dpi, cropBox, rotation, doc.Resources);
    page.Annotations.AddRange(annotations);
}

doc.Save(pdfStream);
Public methodStatic memberCode exampleExportToPdfDocumentSigner
Exports a multiple pages of annotations to PdfDocumentSigner.
Examples
In the following example, annotations are exported to PdfDocumentSigner.
ExportAnnotationsToPdfDocumentSignerExample
var rectData = new RectangleData()
{
    Size = new SizeF(123, 345),
    Location = new PointF(123, 321),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
var polyData = new PolygonData()
{
    Size = new SizeF(100, 200),
    Location = new PointF(10, 11),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
polyData.Points.AddRange(new[] { new PointF(1, 1), new PointF(50, 50), new PointF(1, 50) });


var collection = new AnnotationDataCollection() { new LayerData() { Items = { rectData, polyData } } };
var dpis = new[] { new Dpi(96, 96, ResolutionUnit.DotsPerInch) };
var signer = new PdfDocumentSigner(pdfStream, null);

PdfAnnotationDataConverter.ExportToPdfDocumentSigner(collection, AnnotationUnit.Pixel, dpis, signer);

signer.AppendChangesFinal(true);
Public methodStatic memberCode exampleExportToPdfGeneratedPage
Exports a page of annotations to PdfGeneratedPage.
Examples
In the following example, annotations are exported to PdfGeneratedPage.
ExportAnnotationsToPdfGeneratedPageExample
var rectData = new RectangleData()
{
    Size = new SizeF(123, 345),
    Location = new PointF(123, 321),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
var polyData = new PolygonData()
{
    Size = new SizeF(100, 200),
    Location = new PointF(10, 11),
    Fill = new AnnotationBrush(Color.FromArgb(255, 64, 128, 255)),
    Outline = new AnnotationPen(Color.FromArgb(255, 128, 128, 128))
};
polyData.Points.AddRange(new[] { new PointF(1, 1), new PointF(50, 50), new PointF(1, 50) });


var layer = new LayerData() { Items = { rectData, polyData } };
var dpi = new Dpi(96, 96, ResolutionUnit.DotsPerInch);
var doc = new PdfGeneratedDocument(source);
var page = doc.Pages[0] as PdfGeneratedPage;

if (page != null)
    PdfAnnotationDataConverter.ExportToPdfGeneratedPage(layer, AnnotationUnit.Pixel, dpi,
        page, doc.Resources);

doc.Save(pdfStream);
Top
See Also