Класс PdfPolylineAnnotation
В этом разделе
Представляет PDF аннотацию, отображающую ломаную линию.
Объектная модель
Синтаксис
Пример
Вот пример, показывающий, как создать аннотацию полилинии PDF:
''' <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();
}
}
Иерархия наследования
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также