internal override Annotation Clone(IDocumentEssential owner, Page page) { if (Page == null) { ApplyOwner(owner); SetPage(page, true); float l = Left; float t = Top; float w = Width; float h = Height; float a = RotationAngle; Rectangle = null; Rectangle.Left = l; Rectangle.Top = t; Rectangle.Width = w; Rectangle.Height = h; Rectangle.Angle = a; return(this); } PDFDictionary res = AnnotationBase.Copy(Dictionary); MarkupAnnotationBase.CopyTo(Dictionary, res); TextMarkupAnnotation.CopyTo(Dictionary, res, Page, page); UnderlineAnnotation annot = new UnderlineAnnotation(res, owner); annot.SetPage(page, true); return(annot); }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations(); Document doc = new Document(dataDir + "ExtractHighlightedText.pdf"); // Loop through all the annotations foreach (Annotation annotation in doc.Pages[1].Annotations) { // Filter TextMarkupAnnotation if (annotation is TextMarkupAnnotation) { TextMarkupAnnotation highlightedAnnotation = annotation as TextMarkupAnnotation; // Retrieve highlighted text fragments TextFragmentCollection collection = highlightedAnnotation.GetMarkedTextFragments(); foreach (TextFragment tf in collection) { // Display highlighted text Console.WriteLine(tf.Text); } } } // ExEnd:1 }
private static void AnnotationCallBack(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue is IAnnotation) { CommentView commentView = d as CommentView; if (e.NewValue is ShapeAnnotation) { ShapeAnnotation shape = e.NewValue as ShapeAnnotation; switch (shape.AnnotationType) { case "Line": commentView.SetIcon(commentView.line); break; case "Rectangle": commentView.SetIcon(commentView.rectangle); break; case "Ellipse": commentView.SetIcon(commentView.ellipse); break; } } else if (e.NewValue is InkAnnotation) { commentView.SetIcon(commentView.ink); } else if (e.NewValue is TextMarkupAnnotation) { TextMarkupAnnotation text = e.NewValue as TextMarkupAnnotation; switch (text.AnnotationType) { case "Highlight": commentView.SetIcon(commentView.highlight); break; case "Underline": commentView.SetIcon(commentView.underline); break; case "Strikethrough": commentView.SetIcon(commentView.strike); break; } } else if (e.NewValue is PopupAnnotation) { commentView.SetIcon(commentView.popup); } else if (e.NewValue is FreeTextAnnotation) { if (e.NewValue is FreeTextCalloutAnnotation) { commentView.SetIcon(commentView.callout); } else { commentView.SetIcon(commentView.freeText); } } else if (e.NewValue is StampAnnotation) { commentView.SetIcon(commentView.stamp); } if ((e.NewValue as IAnnotation).Comments[0].Text != "") { commentView.commentBox.Visibility = Visibility.Visible; commentView.textBlock.Visibility = Visibility.Visible; commentView.textBox.Visibility = Visibility.Collapsed; commentView.parent.Height = CommentView.commentViewHeight; } } }