PdfInkAnnotationFacade Class
Contains members used to manage ink annotations without access to their inner structure.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.1.Core.dll
NuGet Package: DevExpress.Pdf.Core
Declaration
Related API Members
The following members return PdfInkAnnotationFacade objects:
Remarks
Create Ink Annotations
The code sample below creates an ink annotation:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Define ink vertices
PdfPoint point1 = new PdfPoint(100, 100);
PdfPoint point2 = new PdfPoint(110, 110);
PdfPoint point3 = new PdfPoint(120, 100);
PdfPoint point4 = new PdfPoint(130, 110);
PdfPoint point5 = new PdfPoint(140, 100);
PdfPoint point6 = new PdfPoint(150, 150);
PdfPoint[] points = new PdfPoint[]
{
point1,
point2,
point3,
point4,
point5,
point6
};
List<IList<PdfPoint>> inks = new List<IList<PdfPoint>> { points };
// Create an ink annotation
PdfInkAnnotationFacade inkAnnotation = pageFacade.AddInkAnnotation(inks);
inkAnnotation.Author = "Brian Zetc";
inkAnnotation.BorderWidth = 1.0;
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Edit Ink Annotations
The PdfPageFacade.Annotations property returns all page annotation properties. You can filter ink annotation properties, cast them to the PdfInkAnnotationFacade class, and use class properties to modify annotation parameters.
The code sample below changes the style and color for all ink annotations on the first page:
using DevExpress.Pdf;
using System.Linq;
//...
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Retrieve all ink annotations
var inkAnnotations = pageFacade.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Ink);
foreach (PdfInkAnnotationFacade ink in inkAnnotations)
{
// Change annotation parameters
ink.Color = new PdfRGBColor(0.80, 0.00, 0.13);
ink.BorderWidth = 2;
ink.BorderStyle = PdfBorderStyle.Dash;
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Flatten Ink Annotations
Call one of the following methods to flatten an annotation:
Method | Description |
---|---|
PdfDocumentFacade.FlattenAnnotations | Flattens document annotations. |
PdfPageFacade.FlattenAnnotations | Flattens annotations of a specific page. |
PdfAnnotationFacade.Flatten() | Flattens a specific annotation. |
The code sample below flattens all ink annotations on the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Flatten all ink annotations
page.FlattenAnnotations(PdfAnnotationType.Ink);
}
Remove Ink Annotations
Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all ink annotations from the first page:
using DevExpress.Pdf;
using System.Linq;
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Retrieve all ink annotations
var inks = page.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Ink).ToList();
// Remove all inks
foreach (PdfInkAnnotationFacade ink in inks)
{
ink.Remove();
}
}