此示例显示如何创建突出显示页面上所选文本的标记注释。 要为选定文本创建此注释,请参考PdfViewerControl.HighlightSelectedText方法。
要在创建标记注释时指定注释属性,请参考PdfViewerControl.TextMarkupAnnotationCreating事件。
PdfViewerControl.HighlightSelectedText方法
突出显示所选文本。
重载列表
1.突出显示所选文本。
public void HighlightSelectedText()
Public Sub HighlightSelectedText()
2.突出显示所选文本,并在此文本中添加注释,该注释将显示在弹出窗口中。
public void HighlightSelectedText( string comment )
Public Sub HighlightSelectedText( ByVal comment As String )
3.突出显示具有指定颜色的选定文本。
public void HighlightSelectedText( Color color )
Public Sub HighlightSelectedText( ByVal color As Color )
4.使用颜色突出显示所选文本,并在此文本中添加注释,该注释将显示在弹出窗口中。
public void HighlightSelectedText( string comment, Color color )
Public Sub HighlightSelectedText( ByVal comment As String, ByVal color As Color )
PdfViewerControl.TextMarkupAnnotationCreating事件
在创建文本标记注释(突出显示,删除线或下划线)时发生。
public event PdfTextMarkupAnnotationCreatingEventHandler TextMarkupAnnotationCreating
event Public TextMarkupAnnotationCreating As PdfTextMarkupAnnotationCreatingEventHandler
此示例显示如何创建突出显示所选文本的标记注释。 要为选定文本创建此注释,请调用HighlightSelectedText重载方法之一。
要在创建标记注释时指定注释属性,请处理TextMarkupAnnotationCreating事件。
using System.Windows; using DevExpress.Pdf; using DevExpress.Xpf.PdfViewer; namespace MarkupAnnotations { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // Load a document. viewer.OpenDocument("..\\..\\Demo.pdf"); // Handle the TextMarkupAnnotationCreating event to specify the annotation properties. viewer.TextMarkupAnnotationCreating += Viewer_TextMarkupAnnotationCreating; } private void Viewer_TextMarkupAnnotationCreating(DependencyObject d, PdfTextMarkupAnnotationCreatingEventArgs e) { e.Author = "John Smith"; e.Comment = "Note."; e.Color = System.Windows.Media.Color.FromRgb(229, 214, 0); } private void viewer_DocumentLoaded(object sender, RoutedEventArgs e) { // Select the document area where the markup annotation will be created. viewer.Select(new PdfDocumentArea(1, new PdfRectangle(90, 100, 240, 230))); // Highlight a selected text. viewer.HighlightSelectedText(); } } }
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:MarkupAnnotations" xmlns:dxpdf="http://schemas.devexpress.com/winfx/2008/xaml/pdf" x:Class="MarkupAnnotations.MainWindow" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <Grid> <dxpdf:PdfViewerControl x:Name="viewer" DocumentLoaded="viewer_DocumentLoaded"/> </Grid> </Window>
Imports System.Windows Imports DevExpress.Pdf Imports DevExpress.Xpf.PdfViewer Namespace MarkupAnnotations Partial Public Class MainWindow Inherits Window Public Sub New() InitializeComponent() ' Load a document. viewer.OpenDocument("..\..\Demo.pdf") ' Handle the TextMarkupAnnotationCreating event to specify the annotation properties. AddHandler viewer.TextMarkupAnnotationCreating, AddressOf Viewer_TextMarkupAnnotationCreating End Sub Private Sub Viewer_TextMarkupAnnotationCreating(ByVal d As DependencyObject, ByVal e As PdfTextMarkupAnnotationCreatingEventArgs) e.Author = "John Smith" e.Comment = "Note." e.Color = System.Windows.Media.Color.FromRgb(229, 214, 0) End Sub Private Sub viewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs) ' Select the document area where the markup annotation will be created. viewer.Select(New PdfDocumentArea(1, New PdfRectangle(90, 100, 240, 230))) ' Highlight a selected text. viewer.HighlightSelectedText() End Sub End Class End Namespace
买 DevExpress Universal Subscription 免费赠 万元汉化资源包1套!
限量15套!先到先得,送完即止!立即抢购>>
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/1213.html