Skip to main content
All docs
V25.1
  • PdfPolyLineAnnotationFacade Class

    Contains members used to manage polyline annotations without access to their inner structure.

    Namespace: DevExpress.Pdf

    Assembly: DevExpress.Pdf.v25.1.Core.dll

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public class PdfPolyLineAnnotationFacade :
        PdfPathAnnotationFacade

    The following members return PdfPolyLineAnnotationFacade objects:

    Remarks

    Create Polyline Annotations

    The code sample below creates a polyline annotation:

    polyline

    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");
    }
    

    Edit Polyline Annotations

    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:

    edit polyline

    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");
    }
    

    Flatten Polyline 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 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");
    }
    

    Remove Polyline Annotations

    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");
    }
    
    See Also