officefileapi-devexpress-dot-pdf-4a10435e.md
Contains members used to manage ink annotations without access to their inner structure.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfInkAnnotationFacade :
PdfMarkupAnnotationFacade
Public Class PdfInkAnnotationFacade
Inherits PdfMarkupAnnotationFacade
The following members return PdfInkAnnotationFacade objects:
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");
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access page properties
Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Define ink vertices
Dim point1 As New PdfPoint(100, 100)
Dim point2 As New PdfPoint(110, 110)
Dim point3 As New PdfPoint(120, 100)
Dim point4 As New PdfPoint(130, 110)
Dim point5 As New PdfPoint(140, 100)
Dim point6 As New PdfPoint(150, 150)
Dim points() As PdfPoint = { point1, point2, point3, point4, point5, point6 }
Dim inks As New List(Of IList(Of PdfPoint))() From {points}
' Create an ink annotation
Dim inkAnnotation As PdfInkAnnotationFacade = pageFacade.AddInkAnnotation(inks)
inkAnnotation.Author = "Brian Zetc"
inkAnnotation.BorderWidth = 1.0
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
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");
}
Imports DevExpress.Pdf
Imports System.Linq
'...
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Retrieve all ink annotations
Dim inkAnnotations = pageFacade.Annotations.Where(Function(annotation) annotation.Type = PdfAnnotationType.Ink)
For Each ink As PdfInkAnnotationFacade In inkAnnotations
' Change annotation parameters
ink.Color = New PdfRGBColor(0.80, 0.00, 0.13)
ink.BorderWidth = 2
ink.BorderStyle = PdfBorderStyle.Dash
Next ink
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
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);
}
Using processor As New PdfDocumentProcessor()
'Load a document:
processor.LoadDocument("..\..\Document.pdf")
' Access the first page's properties
Dim page As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Flatten all ink annotations
page.FlattenAnnotations(PdfAnnotationType.Ink)
End Using
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();
}
}
Imports DevExpress.Pdf
Imports System.Linq
Using processor As New PdfDocumentProcessor()
processor
'Load a document:
processor.LoadDocument("..\..\Document.pdf")
' Access the first page's properties
Dim page As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Retrieve all ink annotations
Dim inks = page.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.Ink).ToList()
' Remove all ink annotataions
For Each ink As PdfInkAnnotationFacade In inks
ink.Remove()
Next ink
End Using
Object PdfAnnotationFacade PdfMarkupAnnotationFacade PdfInkAnnotationFacade
See Also