AddAndBuildAnnotation(WpfPdfAnnotationView) Метод (WpfPdfAnnotationTool)
В этом разделе
Добавляет и создает представление аннотаций.
Синтаксис
Parameters
- view
- Вид аннотации.
Return Value
Представление аннотации, соответствующее аннотации.
Исключения
Пример
Вот C#/VB.NET код, который демонстрирует, как начать создание аннотации к ломаной линии, написанной от руки:
''' <summary>
''' Adds and builds a freehand polyline annotation.
''' </summary>
''' <param name="annotationTool">The PDF annotation tool, which will build an annotation.</param>
Public Shared Sub AddAndBuildFreehandPolylineAnnotation(annotationTool As Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationTool)
Dim focusedPage As Vintasoft.Imaging.Pdf.Tree.PdfPage = annotationTool.FocusedPage
If focusedPage Is Nothing Then
Throw New System.InvalidOperationException()
End If
' create the PDF annotation
Dim annotation As New Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(focusedPage)
annotation.BorderWidth = 5
annotation.Color = System.Drawing.Color.Red
' if tool mode does not allow to build annotation
If annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.None OrElse annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.View Then
' change the tool mode
annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.Markup
End If
' create the annotation view because view parameters must be changed
Dim view As Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfPolygonalAnnotationView = New Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfPolylineAnnotationView(annotation, annotationTool.FocusedJsDoc)
' set the builder for annotation view
view.Builder = New Vintasoft.Imaging.Wpf.UI.VisualTools.UserInteraction.WpfPointBasedObjectFreehandBuilder(view, 2, 0.1F)
' add and build annotation
annotationTool.AddAndBuildAnnotation(view)
End Sub
/// <summary>
/// Adds and builds a freehand polyline annotation.
/// </summary>
/// <param name="annotationTool">The PDF annotation tool, which will build an annotation.</param>
public static void AddAndBuildFreehandPolylineAnnotation(
Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationTool annotationTool)
{
Vintasoft.Imaging.Pdf.Tree.PdfPage focusedPage = annotationTool.FocusedPage;
if (focusedPage == null)
throw new System.InvalidOperationException();
// create the PDF annotation
Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation annotation =
new Vintasoft.Imaging.Pdf.Tree.Annotations.PdfPolylineAnnotation(focusedPage);
annotation.BorderWidth = 5;
annotation.Color = System.Drawing.Color.Red;
// if tool mode does not allow to build annotation
if (annotationTool.InteractionMode == Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.None ||
annotationTool.InteractionMode == Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.View)
// change the tool mode
annotationTool.InteractionMode = Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfAnnotationInteractionMode.Markup;
// create the annotation view because view parameters must be changed
Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfPolygonalAnnotationView view =
new Vintasoft.Imaging.Pdf.Wpf.UI.Annotations.WpfPdfPolylineAnnotationView(annotation, annotationTool.FocusedJsDoc);
// set the builder for annotation view
view.Builder = new Vintasoft.Imaging.Wpf.UI.VisualTools.UserInteraction.WpfPointBasedObjectFreehandBuilder(view, 2, 0.1f);
// add and build annotation
annotationTool.AddAndBuildAnnotation(view);
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также