/// <summary> /// Puts a highlight rectangle over the box which is expressed in PDF coordinate space /// </summary> /// <param name="p">A PDF Text page</param> /// <param name="v">The viewer to put the annotation on</param> /// <param name="layer">The layer to put the annotation on</param> /// <param name="pdfBox">The box to highlight in PDF coordinate space</param> /// <param name="hiColor">The color to highlight with</param> /// <param name="padding">Extra padding around the box in pixels</param> private void HighlightPdfBox(PdfTextPage p, AnnotateViewer v, LayerAnnotation layer, RectangleF pdfBox, Color hiColor, int padding) { RectangleF imageBox = p.ConvertPdfUnitsToPixels(new QuadrilateralF(pdfBox), v.Image.Resolution).Bounds; imageBox.X = imageBox.X - padding; imageBox.Y = imageBox.Y - padding; imageBox.Width = imageBox.Width + 2 * padding; imageBox.Height = imageBox.Height + 2 * padding; HighlightImageBox(v, layer, imageBox, hiColor); }
/// <summary> /// Put an annotation on the layer that highlights the rectangle in the color passed in /// </summary> /// <param name="layer">The layer on which to put the annotation</param> /// <param name="imageBox">The bounds of the annotation</param> /// <param name="hiColor">The color of the annotation</param> private void CreateHighlightAnnotation(LayerAnnotation layer, RectangleF imageBox, Color hiColor) { RectangleAnnotation ra = new RectangleAnnotation(imageBox, new AnnotationBrush(hiColor), null) { Translucent = true }; ra.Data.CanMove = false; ra.Data.CanResize = false; ra.Data.CanSelect = false; ra.Data.CanRotate = false; layer.Items.Add(ra); }
private LayerData[] LoadAnnotationData(object data) { LayerData[] layers = null; LayerCollection lc = data as LayerCollection; if (lc != null && lc.Count != 0) { layers = new LayerData[lc.Count]; for (int i = 0; i < layers.Length; i++) { layers[i] = (LayerData)lc[i].Data; } } LayerData[] lda = data as LayerData[]; if (lda != null) { layers = lda; } LayerAnnotation la = data as LayerAnnotation; if (la != null) { layers = new LayerData[1]; layers[0] = (LayerData)la.Data; } LayerData ld = data as LayerData; if (ld != null) { layers = new LayerData[1]; layers[0] = ld; } AnnotationUI ann = data as AnnotationUI; if (ann != null) { layers = new LayerData[1]; layers[0].Items.Add(ann.Data); } AnnotationData ad = data as AnnotationData; if (ad != null) { layers = new LayerData[1]; layers[0].Items.Add(ad); } return layers; }
private void SetContextMenu(Atalasoft.Annotate.UI.LayerAnnotation layer) { foreach (Atalasoft.Annotate.UI.AnnotationUI ann in layer.Items) { LayerAnnotation l = ann as LayerAnnotation; if (l != null) { SetContextMenu(l); } else { ann.ContextMenuStrip = this.contextMenuStrip1; } } }
/// <summary> /// Puts an annotation over the characters in a PDF page /// </summary> /// <param name="v">Annotate viewer</param> /// <param name="p">A PDF Text page</param> /// <param name="hiColor">The highlight color</param> /// <param name="index">The index of the first character within the page</param> /// <param name="len">The number of characters to highlight</param> private void HighlightChars(AnnotateViewer v, PdfTextPage p, Color hiColor, int index, int len) { // take off all existing hilights LayerAnnotation layer = v.Annotations.CurrentLayer; layer.Items.Clear(); // a single phrase can span a line and need more than one box to // highlight it QuadrilateralF[] pdfBoxes = p.GetBoxes(index, len); foreach (QuadrilateralF b in pdfBoxes) { HighlightPdfBox(p, v, layer, b.Bounds, hiColor, 2); } }
public LayerCollection ToAnnotationUI(LayerData[] layers, Size[] pageSizes) { LayerCollection retLayers = new LayerCollection(); if (layers != null) { ConvertFromWDV(layers, pageSizes); foreach (LayerData layer in layers) { AnnotationUI outAnnot = _factories.GetAnnotationFromData(layer); LayerAnnotation layerAnnot = outAnnot as LayerAnnotation; retLayers.Add(layerAnnot); } } return retLayers; }
/// <summary> /// Puts a highlight rectangle over the box which is expressed in the image's coordinate space /// </summary> /// <param name="layer">The layer to put the annotation on</param> /// <param name="imageBox">The box to highlight in Image coordinate space</param> /// <param name="hiColor">The color to highlight with</param> private void HighlightImageBox(AnnotateViewer v, LayerAnnotation layer, RectangleF imageBox, Color hiColor) { CreateHighlightAnnotation(layer, imageBox, hiColor); EnsureAreaIsVisible(v, imageBox); }