Esempio n. 1
0
 private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
    var text=(string)  barEditItem1.EditValue;
     PdfTextSearchParameters searchParam=new PdfTextSearchParameters();
     searchParam.CaseSensitive=false;
    var results= pdfViewer.FindText(text, searchParam);
 }
 private void pdfViewer1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.F3)
     {
         PdfTextSearchParameters parameters = new PdfTextSearchParameters();
         PdfFindDialogOptions    options    = pdfViewer1.FindDialogOptions;
         parameters.CaseSensitive = options.CaseSensitive;
         parameters.WholeWords    = options.WholeWords;
         pdfViewer1.FindText(options.Text, parameters);
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // Create a PDF document processor.
            using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
                // Define search words.
                string[] words = { "DX-B5000", "DX-RX800" };

                // Load a PDF document.
                documentProcessor.LoadDocument(@"..\..\Document.pdf");

                // Specify the search parameters.
                PdfTextSearchParameters searchParameters = new PdfTextSearchParameters();
                searchParameters.CaseSensitive = true;
                searchParameters.WholeWords    = true;

                // Get bookmark list.
                IList <PdfBookmark> bookmarks = documentProcessor.Document.Bookmarks;
                foreach (string word in words)
                {
                    // Get the search results from the FindText method called with search text and search parameters.
                    PdfTextSearchResults results = documentProcessor.FindText(word, searchParameters);

                    // If the desired text is found, create a destination that corresponds to the found text
                    // to be displayed at the upper corner of the window.
                    if (results.Status == PdfTextSearchStatus.Found)
                    {
                        PdfXYZDestination destination = new PdfXYZDestination(results.Page, 0, results.Rectangles[0].Top, null);

                        // Create a bookmark with the search word shown as title and the destination.
                        PdfBookmark bookmark = new PdfBookmark()
                        {
                            Title = word, Destination = destination
                        };

                        // Add the bookmark to the bookmark list.
                        bookmarks.Add(bookmark);
                    }
                }
                // Save the modified document.
                documentProcessor.SaveDocument(@"..\..\Result.pdf");
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //Create a PDF document processor.
            using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor())
            {
                //Define search words
                string[] words = { "Get", "DX-RX809", "HD", "DX-B5000" };

                //Load a PDF document
                documentProcessor.LoadDocument(@"..\..\Document.pdf");

                //Specify the search parameters
                PdfTextSearchParameters searchParameters = new PdfTextSearchParameters();
                searchParameters.CaseSensitive = true;
                searchParameters.WholeWords    = true;


                //Comment the following "using" statement if you use annotations
                using (var brush = new SolidBrush(Color.FromArgb(130, 55, 155, 255)))
                    foreach (string word in words)
                    {
                        //Get the search results from the FindText method call with search text and search parameters
                        PdfTextSearchResults result = documentProcessor.FindText(word, searchParameters);

                        //Highlight the result
                        while (result.Status == PdfTextSearchStatus.Found)
                        {
                            using (PdfGraphics graphics = documentProcessor.CreateGraphics())
                            {
                                HighlightResult(graphics, result, brush);
                            }
                            //Use this method call to add annotations:
                            //HighlightResult(documentProcessor, result);
                            result = documentProcessor.FindText(word, searchParameters);
                        }
                    }
                //Save the document
                documentProcessor.SaveDocument(@"..\..\Result.pdf");
            }
        }
Esempio n. 5
0
        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var pdfViewer1 = new PdfViewer();
            var pdfStream = File.OpenRead(@"C:\Users\Public\Documents\DevExpress Demos 14.1\Components\WinForms\CS\PdfViewerDemo\Data\Demo.pdf");
            pdfViewer1.LoadDocument(pdfStream);

            var text = (string)barEditItem1.EditValue;
            PdfTextSearchParameters searchParam = new PdfTextSearchParameters();
            searchParam.CaseSensitive = false;
            searchParam.Direction = PdfTextSearchDirection.Forward;
            PdfTextSearchResults results = pdfViewer1.FindText(text, searchParam);
            List<int> findPages = new List<int>();

            while (results.Words !=null )
            {
                findPages.Add(results.PageNumber);
                results = pdfViewer1.FindText(text, searchParam);
            }
        }