logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Friday, February 5, 2016 3:23:15 AM(UTC)
 
Originally Posted by: eagleview Go to Quoted Post
Hi Paul,
But how can I now highlight the OCR text in the viewer. The application highlights keywords in the PDF and works fine when it is a text PDF. But how does the PdfViewer highlight method work on an Tesseract OCR?


I can recommend to create searchable PDF via Tesseract and then load it into PdfViewer

Originally Posted by: eagleview Go to Quoted Post

A related question concerns your use of scaling factor in the code you provided.

answer here

eagleview Posted: Thursday, February 4, 2016 7:23:47 AM(UTC)
 
Hi Paul,

Below is the code that you provided as an example. It works well and I figured out why the PdfViewer as displaying a gray box after the render. It seems I have to display the image PDF with the viewer and separately OCR the document. But how can I now highlight the OCR text in the viewer. The application highlights keywords in the PDF and works fine when it is a text PDF. But how does the PdfViewer highlight method work on an Tesseract OCR?

A related question concerns your use of scaling factor in the code you provided. In the PDFium User info there is an example of render but without scaling the height and width. Your example uses a scaling factor. What is the purpose of the scaling factor? This may be important because the OCR routine is not finding small characters. Even though the PDF is high quality image, Tesseract is missing some characters (U.S. becomes US. for example). Will increasing the scaling factor help?

Also, does PDF user space mean Points (1/72)? I've tried a number of different PDFs and all have a width of 612 and height of 792 no matter where the PDF comes from...I've also changed the PDFViewer and ScrollViewer sizes in the XMAL file (designer) and still I have same size of 612 and 792. My goal is to figure out the different coordinate systems in the PDF & WPF controls. I'm figuring that the scaling factor is for the 3 bytes per pixel (but not sure).

Thanks!!


using (var doc = PdfDocument.Load(@"d:\1\1.pdf"))
{
foreach(var page in doc.Pages)
{
int width = (int)(page.Width * scaleFactor);
int height = (int)(page.Height * scaleFactor);
using (var bitmap = new PdfBitmap(width, height, true))
{
page.Render(bitmap, 0, 0, width, height, PageRotate.Normal, RenderFlags.FPDF_LCD_TEXT);
string text = ocr.GetTextFromImage(bitmap.Image as Bitmap);
}
}
}
Paul Rayman Posted: Thursday, February 4, 2016 12:56:46 AM(UTC)
 
Originally Posted by: eagleview Go to Quoted Post
Hi,

I've used page.Render to render a page from an image pdf for OCR. How do I display the rendered page back to the PdfViewer window?


Hi,

What for? PdfViewer render pages itself
eagleview Posted: Wednesday, February 3, 2016 9:08:53 AM(UTC)
 
Hi,

I've used page.Render to render a page from an image pdf for OCR. How do I display the rendered page back to the PdfViewer window?

I'm getting a gray box in place of the PdfViewer. The Pdf displays fine before I call page.render. I've tried page.GenerateContent() and that did not work. BTW - is there more examples available? Other that the initial usage page on how to add Pdfium to VS, I only can find the SDK methods but no examples on how to use most of the methods.

Thanks,

Michael