Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Tue Jan 09, 2024 8:08 pm

Is it possible to select a text in the PdfViewer with the mouse and read out the selected text?

Best Regards
Peter

peterInStIngbert
 
Posts: 14
Joined: Wed Nov 25, 2020 2:08 pm

Wed Jan 10, 2024 3:10 am

Hello,

Thank you for your inquiry.
I regret to inform you that our Spire.PdfViewer currently does not support the requested feature. However, I have added this feature to our upgrade list with the identifier SPIREPDFVIEWER-454. Once this feature is implemented in the future, I will promptly notify you.
We apologize for any inconvenience caused and appreciate your understanding. If you have any further questions or require additional assistance, please feel free to let me know.

Best regards,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Jan 11, 2024 7:18 am

Hello
Thanks for the information.
Can you estimate how long it will take until the SPIREPDFVIEWER-454 feature is implemented?
If it is a few weeks or months that would not be a problem, otherwise I need another tool.

Regards
Peter

peterInStIngbert
 
Posts: 14
Joined: Wed Nov 25, 2020 2:08 pm

Thu Jan 11, 2024 7:48 am

Hello,

Thank you for your follow-up. We appreciate your patience.
Regarding the SPIREPDFVIEWER-454 issue, our development team is currently investigating the feasibility of implementing this feature. Unfortunately, we do not have an estimated timeline for its implementation at this moment.
Rest assured that once our developers complete their evaluation and provide an estimated time for implementing this feature, I will promptly inform you.
We understand the importance of this functionality to you, and we are committed to keeping you updated on any progress. Should you have any further questions or need assistance with any other matter, please feel free to reach out.
Thank you for your continued support.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Feb 07, 2024 9:32 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.PDFViewer Pack(Hotfix) Version:7.12.6 which fixes the issue of SPIREPDFVIEWER-454.please download and refer to the sample code for testing.
Website download link: https://www.e-iceblue.com/Download/download-pdf-viewer-for-net-now.html
Nuget download link:https://www.nuget.org/packages/Spire.PDFViewer/7.12.6
Code: Select all
     private void Form1_Load(object sender, EventArgs e)
       {
          this.pdfDocumentViewer1.LoadFromFile("1.pdf");
          this.pdfDocumentViewer1.MouseDown += new MouseEventHandler(PV_Click);
        }

        private void PV_Click(object sender, MouseEventArgs e)
        {
            string outputFile = "out.Pdf";
            string outputFile_TXT = "out.txt";
            File.Delete(outputFile_TXT);           
           if (e.Button == MouseButtons.Left)
           {
                PointF[] controlPositions = new PointF[] { e.Location};
                Spire.PdfViewer.Forms.PagePosition[] pagePositions = this.pdfDocumentViewer1.ControlToPage(controlPositions);               
   string fileName = this.pdfDocumentViewer1.FileName;
                PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(fileName,FileFormat.PDF);               
   PdfPageBase page = doc.Pages[pagePositions[0].PageIndex];
             
                RectangleF bounds = new RectangleF(pagePositions[0].Position, new SizeF(100, 100));           
                PdfTextExtractor textExtractor = new PdfTextExtractor(page);
                PdfTextExtractOptions option = new PdfTextExtractOptions();
                option.ExtractArea = bounds;
                string text = textExtractor.ExtractText(option);         
                PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11);
                PdfTextWidget pdfTextbox = new PdfTextWidget();
                pdfTextbox.Font = font;
                pdfTextbox.Brush = PdfBrushes.Red;
                pdfTextbox.Text = "stamp";               
   pdfTextbox.Draw(page, bounds);               
   doc.Pages[pagePositions[0].PageIndex].Canvas.DrawRectangle(PdfPens.Red, bounds);
                doc.SaveToFile(outputFile);               
   File.AppendAllText(outputFile_TXT, "Position: " + pagePositions[0].Position.ToString() + "\ntext:\r\n " + text);               
   MessageBox.Show("finish");               
   doc.Dispose();
            }
        }

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Apr 05, 2024 12:48 pm

Sorry for the late reply

It works perfectly

Thank you
Peter


Annika.Zhou wrote:Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.PDFViewer Pack(Hotfix) Version:7.12.6 which fixes the issue of SPIREPDFVIEWER-454.please download and refer to the sample code for testing.
Website download link: https://www.e-iceblue.com/Download/download-pdf-viewer-for-net-now.html
Nuget download link:https://www.nuget.org/packages/Spire.PDFViewer/7.12.6
Code: Select all
     private void Form1_Load(object sender, EventArgs e)
       {
          this.pdfDocumentViewer1.LoadFromFile("1.pdf");
          this.pdfDocumentViewer1.MouseDown += new MouseEventHandler(PV_Click);
        }

        private void PV_Click(object sender, MouseEventArgs e)
        {
            string outputFile = "out.Pdf";
            string outputFile_TXT = "out.txt";
            File.Delete(outputFile_TXT);           
           if (e.Button == MouseButtons.Left)
           {
                PointF[] controlPositions = new PointF[] { e.Location};
                Spire.PdfViewer.Forms.PagePosition[] pagePositions = this.pdfDocumentViewer1.ControlToPage(controlPositions);               
   string fileName = this.pdfDocumentViewer1.FileName;
                PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(fileName,FileFormat.PDF);               
   PdfPageBase page = doc.Pages[pagePositions[0].PageIndex];
             
                RectangleF bounds = new RectangleF(pagePositions[0].Position, new SizeF(100, 100));           
                PdfTextExtractor textExtractor = new PdfTextExtractor(page);
                PdfTextExtractOptions option = new PdfTextExtractOptions();
                option.ExtractArea = bounds;
                string text = textExtractor.ExtractText(option);         
                PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11);
                PdfTextWidget pdfTextbox = new PdfTextWidget();
                pdfTextbox.Font = font;
                pdfTextbox.Brush = PdfBrushes.Red;
                pdfTextbox.Text = "stamp";               
   pdfTextbox.Draw(page, bounds);               
   doc.Pages[pagePositions[0].PageIndex].Canvas.DrawRectangle(PdfPens.Red, bounds);
                doc.SaveToFile(outputFile);               
   File.AppendAllText(outputFile_TXT, "Position: " + pagePositions[0].Position.ToString() + "\ntext:\r\n " + text);               
   MessageBox.Show("finish");               
   doc.Dispose();
            }
        }

Sincerely,
Annika
E-iceblue support team

peterInStIngbert
 
Posts: 14
Joined: Wed Nov 25, 2020 2:08 pm

Sun Apr 07, 2024 6:52 am

Hello,

You're welcome.
If you encounter other issues related to our products in the future, please feel free to contact us.
Have a nice day.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Apr 17, 2024 3:02 pm

Nowadays, most mainstream PDF viewers support the function of mouse-selecting text with the mouse, and if you right click upon the selected text, a context menu usually appears that contains an option for reading out the text. This function is designed specifically for those individuals who get their knowledge through audio or for those people who rely on text reading aloud technology for (accessibility) accessibility. If you come across any problems with this function, you might need to enable particular configuration options or plugins available for your PDF viewer.

PixelPioneer
 
Posts: 5
Joined: Fri Apr 12, 2024 6:43 am

Thu Apr 18, 2024 9:53 am

PixelPioneer wrote:Nowadays, most mainstream PDF viewers support the function of mouse-selecting text with the mouse, and if you right click upon the selected text, a context menu usually appears that contains an option for reading out the text. This function is designed specifically for those individuals who get their knowledge through audio or for those people who rely on text reading aloud technology for (accessibility) accessibility. If you come across any problems with this function, you might need to enable particular configuration options or plugins available for your PDF viewer.


Hi,

Thanks for your messages.
Actually, we can first get the expected position from Pdf file through Spire.PdfViewer, then create tagged Pdf file in the expected position through Spire.Pdf. And you can refer to the help document from the following link to create tagged Pdf file.

https://www.e-iceblue.com/Tutorials/NET ... ument.html

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDFViewer

cron