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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
eagleview  
#1 Posted : Wednesday, February 3, 2016 9:08:53 AM(UTC)
Quote
eagleview

Rank: Member

Groups: Registered
Joined: 1/28/2016(UTC)
Posts: 17
United States

Thanks: 3 times
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
Paul Rayman  
#2 Posted : Thursday, February 4, 2016 12:56:46 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
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

Edited by user Friday, February 5, 2016 3:17:43 AM(UTC)  | Reason: Not specified

eagleview  
#3 Posted : Thursday, February 4, 2016 7:23:47 AM(UTC)
Quote
eagleview

Rank: Member

Groups: Registered
Joined: 1/28/2016(UTC)
Posts: 17
United States

Thanks: 3 times
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);
}
}
}

Edited by moderator Thursday, March 31, 2016 2:28:00 AM(UTC)  | Reason: Not specified

Paul Rayman  
#4 Posted : Friday, February 5, 2016 3:23:15 AM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,138

Thanks: 10 times
Was thanked: 133 time(s) in 130 post(s)
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

Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.