PdfInkAnnotationFacade Class
Contains members used to manage ink annotations without access to their inner structure.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v25.1.Core.dll
NuGet Package: DevExpress.Pdf.Core
Declaration
Related API Members
The following members return PdfInkAnnotationFacade objects:
Remarks
Create Ink Annotations
The following code snippet 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[] points = new PdfPoint[]
{
new PdfPoint(100, 100),
new PdfPoint(120, 100),
new PdfPoint(130, 110),
new PdfPoint(130, 110),
new PdfPoint(140, 100),
new PdfPoint(150, 150)
};
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 following code snippet 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's 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 following code snippet flattens all ink annotations on the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page's 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 following code snippet 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's properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Retrieve all ink annotations
var inks = page.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Ink).ToList();
// Remove all ink annotations
foreach (PdfInkAnnotationFacade ink in inks)
{
ink.Remove();
}
}