コード例 #1
0
        /// <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);
        }
コード例 #2
0
        public ExplorerPanel(MainForm mainForm)
        {
            this.mainForm = mainForm;
            this.process  = mainForm.Process;
            InitializeComponent();

            PageBase page = new PdfTextPage(this);

            this.tbcMain.TabPages[1].Controls.Add(page);
            page.Dock = DockStyle.Fill;
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #4
0
 /// <summary>
 /// Highlights the found text on the PDF, makes sure the page is selected and the scroll
 /// position is set so that the highlight can be seen
 /// </summary>
 /// <param name="pdfPage">The PDF Page with the text on it</param>
 /// <param name="pageNum">The page number (0-based)</param>
 /// <param name="charIndex">The index of the first character to highlight</param>
 /// <param name="len">The length of the text to highlight</param>
 public void HighlightFoundText(PdfTextPage pdfPage, int pageNum, int charIndex, int len)
 {
     SelectThumb(_thumbnailViewer, pageNum);
     HighlightChars(_viewer, pdfPage, _hiColor, charIndex, len);
 }