VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Tree.Annotations Namespace / PdfPolylineAnnotation Class
Members Example



In This Topic
    PdfPolylineAnnotation Class
    In This Topic
    Represents a PDF annotation that displays a polyline.
    Object Model
    PdfPolylineAnnotation ClassPdfAction ClassPdfAnnotationAdditionalActions ClassPdfAnnotationAppearanceGenerator ClassPdfAnnotationAppearances ClassPdfFileReferenceSpecificationList ClassPdfFileReferenceSpecification ClassPdfBasicObject ClassPdfAnnotationBorderStyle ClassPdfDocument ClassPdfIndirectReference ClassPdfOptionalContentGroup ClassPdfPage Class
    Syntax
    'Declaration
     
    Public NotInheritable Class PdfPolylineAnnotation 
       Inherits PdfPolygonalAnnotation
    public sealed class PdfPolylineAnnotation : PdfPolygonalAnnotation 
    public __gc __sealed class PdfPolylineAnnotation : public PdfPolygonalAnnotation 
    public ref class PdfPolylineAnnotation sealed : public PdfPolygonalAnnotation 
    Example
    This example shows how to create a PDF polyline annotation.
    ''' <summary>
    ''' Creates the PDF documenet with polyline annotation.
    ''' </summary>
    ''' <param name="outputPdfFilename">The output PDF filename.</param>
    Public Shared Sub CreatePdfPolylineAnnotation(outputPdfFilename As String)
    	Using document As New Vintasoft.Imaging.Pdf.PdfDocument(outputPdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14)
    		Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage
                
    		' Add new page
    		page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4)
    		page.Annotations = New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document)
    		Dim annotationRectangle As System.Drawing.RectangleF = page.MediaBox
    		annotationRectangle.Inflate(-200, -300)
                
    		' Points
    		Dim random As New System.Random()
    		Dim polylgonalAnnotationPoints As System.Drawing.PointF() = New System.Drawing.PointF(9) {}
    		polylgonalAnnotationPoints(0) = annotationRectangle.Location
    		For i As Integer = 1 To polylgonalAnnotationPoints.Length - 1
    			polylgonalAnnotationPoints(i) = New System.Drawing.PointF(annotationRectangle.X + annotationRectangle.Width * CSng(random.NextDouble()), annotationRectangle.Y + annotationRectangle.Height * CSng(random.NextDouble()))
    		Next
                
    		' Polyline annotation
    		Dim polyline As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(page)
    		polyline.Rectangle = System.Drawing.RectangleF.Inflate(annotationRectangle, 30, 30)
    		polyline.Points = polylgonalAnnotationPoints
    		polyline.BorderWidth = 3
    		polyline.InteriorColor = System.Drawing.Color.Red
    		polyline.Color = System.Drawing.Color.Green
    		polyline.StartPointLineEndingStyle = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.ClosedArrow
    		polyline.EndPointLineEndingStyle = Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.Diamond
    		polyline.UpdateAppearance()
    		page.Annotations.Add(polyline)
                
    		document.SaveChanges()
    	End Using
    End Sub
    /// <summary>
    /// Creates the PDF documenet with polyline annotation.
    /// </summary>
    /// <param name="outputPdfFilename">The output PDF filename.</param>
    public static void CreatePdfPolylineAnnotation(string outputPdfFilename)
    {
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(
            outputPdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_14))
        {
            Vintasoft.Imaging.Pdf.Tree.PdfPage page;
                
            // Add new page
            page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4);
            page.Annotations = new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList(document);
            System.Drawing.RectangleF annotationRectangle = page.MediaBox;
            annotationRectangle.Inflate(-200, -300);
                
            // Points
            System.Random random = new System.Random();
            System.Drawing.PointF[] polylgonalAnnotationPoints = new System.Drawing.PointF[10];
            polylgonalAnnotationPoints[0] = annotationRectangle.Location;
            for (int i = 1; i < polylgonalAnnotationPoints.Length; i++)
            {
                polylgonalAnnotationPoints[i] = new System.Drawing.PointF(
                    annotationRectangle.X + annotationRectangle.Width * (float)random.NextDouble(),
                    annotationRectangle.Y + annotationRectangle.Height * (float)random.NextDouble());
            }
                
            // Polyline annotation
            Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation polyline = 
                new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(page);
            polyline.Rectangle = System.Drawing.RectangleF.Inflate(annotationRectangle, 30, 30);
            polyline.Points = polylgonalAnnotationPoints;
            polyline.BorderWidth = 3;
            polyline.InteriorColor = System.Drawing.Color.Red;
            polyline.Color = System.Drawing.Color.Green;
            polyline.StartPointLineEndingStyle = 
                Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.ClosedArrow;
            polyline.EndPointLineEndingStyle = 
                Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationLineEndingStyle.Diamond;
            polyline.UpdateAppearance();
            page.Annotations.Add(polyline);
                
            document.SaveChanges();
        }
    }
    Inheritance Hierarchy
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also