officefileapi-devexpress-dot-pdf-bfc08cba.md
Contains members used to manage polyline annotations without access to their inner structure.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfPolyLineAnnotationFacade :
PdfPathAnnotationFacade
Public Class PdfPolyLineAnnotationFacade
Inherits PdfPathAnnotationFacade
The following members return PdfPolyLineAnnotationFacade objects:
The code sample below creates a polyline annotation:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Define polyline 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[] points = new PdfPoint[] { point1, point2, point3, point4, point5 };
// Create an annotation
PdfPolyLineAnnotationFacade polylineAnnotation = pageFacade.AddPolyLineAnnotation(points);
// Specify annotation parameters
polylineAnnotation.Author = "Rayn Anita W";
polylineAnnotation.Contents = "Made in PDF Document API";
polylineAnnotation.BorderWidth = 6;
polylineAnnotation.Color = new PdfRGBColor(0.8, 0.2, 0.1);
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
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)
' Define polyline 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 points() As PdfPoint = { point1, point2, point3, point4, point5 }
' Create an annotation
Dim polylineAnnotation As PdfPolyLineAnnotationFacade = pageFacade.AddPolyLineAnnotation(points)
' Specify annotation parameters
polylineAnnotation.Author = "Rayn Anita W"
polylineAnnotation.Contents = "Made in PDF Document API"
polylineAnnotation.BorderWidth = 6
polylineAnnotation.Color = New PdfRGBColor(0.8, 0.2, 0.1)
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
The PdfPageFacade.Annotations property returns all page annotation properties. You can filter polyline annotation properties, cast them to the PdfPolylineAnnotationFacade class, and use class properties to modify annotation parameters.
The code sample below retrieves all polyline annotations on the first page and changes their border and endings’ style:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Obtain all polyline annotations
var polyLines = pageFacade.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.PolyLine);
foreach (PdfPolyLineAnnotationFacade polyLine in polyLines)
{
// Change annotation parameters
polyLine.BorderStyle = PdfBorderStyle.Dot;
polyLine.LineEndStyle = PdfAnnotationLineEndingStyle.Butt;
polyLine.LineStartStyle = PdfAnnotationLineEndingStyle.Butt;
polyLine.BorderWidth = 3;
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
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)
' Obtain all polyline annotations
Dim polyLines = pageFacade.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.PolyLine)
For Each polyLine As PdfPolyLineAnnotationFacade In polyLines
' Change annotation parameters
polyLine.BorderStyle = PdfBorderStyle.Dot
polyLine.LineEndStyle = PdfAnnotationLineEndingStyle.Butt
polyLine.LineStartStyle = PdfAnnotationLineEndingStyle.Butt
polyLine.BorderWidth = 3
Next polyLine
' 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 code sample below flattens all polyline annotations on the first page:
using DevExpress.Pdf;
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Flatten all polyline annotations
pageFacade.FlattenAnnotations(PdfAnnotationType.PolyLine);
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
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)
' Flatten all polyline annotations
pageFacade.FlattenAnnotations(PdfAnnotationType.PolyLine)
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all polyline annotations from the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];
// Obtain all polyline annotations
var polyLines = pageFacade.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.PolyLine).ToList();
foreach (PdfPolyLineAnnotationFacade polyline in polyLines)
{
// Remove all polyline annotations
polyline.Remove();
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
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)
' Obtain all polyline annotations
Dim polyLines = pageFacade.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.PolyLine).ToList()
For Each polyline As PdfPolyLineAnnotationFacade In polyLines
' Remove all polyline annotations
polyline.Remove()
Next polyline
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Object PdfAnnotationFacade PdfMarkupAnnotationFacade PdfPathAnnotationFacade PdfPolyLineAnnotationFacade
See Also