officefileapi-devexpress-dot-pdf-fa1c1121.md
Contains members used to manage line annotations without access to their inner structure.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfLineAnnotationFacade :
PdfPathAnnotationFacade
Public Class PdfLineAnnotationFacade
Inherits PdfPathAnnotationFacade
The following members return PdfLineAnnotationFacade objects:
The code sample below creates a red line 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 an annotation's start and end points
PdfPoint start = new PdfPoint(100, 100);
PdfPoint end = new PdfPoint(150, 100);
// Add a line annotation
PdfLineAnnotationFacade lineAnnotation = pageFacade.AddLineAnnotation(start, end);
// Specify the annotation parameters
lineAnnotation.Author = "Brian Zetc";
lineAnnotation.BorderStyle = PdfBorderStyle.DashDot;
lineAnnotation.BorderWidth = 3;
lineAnnotation.Color = new PdfRGBColor(0.8, 0.2, 0.1);
lineAnnotation.Contents = "Made in PDF Document API";
// 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 an annotation's start and end points
Dim start As New PdfPoint(100, 100)
Dim [end] As New PdfPoint(150, 100)
' Add a line annotation
Dim lineAnnotation As PdfLineAnnotationFacade = pageFacade.AddLineAnnotation(start, [end])
' Specify the annotation parameters
lineAnnotation.Author = "Brian Zetc"
lineAnnotation.BorderStyle = PdfBorderStyle.DashDot
lineAnnotation.BorderWidth = 3
lineAnnotation.Color = New PdfRGBColor(0.8, 0.2, 0.1)
lineAnnotation.Contents = "Made in PDF Document API"
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
The PdfPageFacade.Annotations property returns all page annotation properties. You can filter line annotation properties, cast them to the PdfLineAnnotationFacade class, and use class properties to modify annotation parameters.
The code sample below retrieves all line annotations on the first page and changes their end style and interior color used to fill the annotation’s line endings:
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 line annotations
var lineAnnotations = pageFacade.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Line);
foreach (PdfLineAnnotationFacade lineAnnotation in lineAnnotations)
{
// Change each line's interior color and ending style
lineAnnotation.InteriorColor = new PdfRGBColor(0.8, 0.2, 0.1);
lineAnnotation.LineStartStyle = PdfAnnotationLineEndingStyle.Diamond;
lineAnnotation.LineEndStyle = PdfAnnotationLineEndingStyle.ClosedArrow;
}
// 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 line annotations
Dim lineAnnotations = pageFacade.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.Line)
For Each lineAnnotation As PdfLineAnnotationFacade In lineAnnotations
' Change each line's interior color and ending styles
lineAnnotation.InteriorColor = New PdfRGBColor(0.8, 0.2, 0.1)
lineAnnotation.LineStartStyle = PdfAnnotationLineEndingStyle.Diamond
lineAnnotation.LineEndStyle = PdfAnnotationLineEndingStyle.ClosedArrow
Next lineAnnotation
' 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 line 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 line annotations
pageFacade.FlattenAnnotations(PdfAnnotationType.Line);
// 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 line annotations
pageFacade.FlattenAnnotations(PdfAnnotationType.Line)
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all line 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 line annotations
var lineAnnotations = pageFacade.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.Line).ToList();
foreach (PdfLineAnnotationFacade lineAnnotation in lineAnnotations)
{
// Remove all annotations
lineAnnotation.Remove();
}
// 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 line annotations
Dim lineAnnotations = pageFacade.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.Line).ToList()
For Each lineAnnotation As PdfLineAnnotationFacade In lineAnnotations
' Remove all annotations
lineAnnotation.Remove()
Next lineAnnotation
' Save the result
processor.SaveDocument("..\..\Result.pdf")
End Using
Object PdfAnnotationFacade PdfMarkupAnnotationFacade PdfPathAnnotationFacade PdfLineAnnotationFacade
See Also