Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Render a page in a correct DPI
  FAQ FAQ  Forum Search   Register Register  Login Login

Render a page in a correct DPI

 Post Reply Post Reply
Author
Message
moi meme View Drop Down
Beginner
Beginner


Joined: 22 Nov 10
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote moi meme Quote  Post ReplyReply Direct Link To This Post Topic: Render a page in a correct DPI
    Posted: 09 Mar 11 at 2:20PM
Hello,

I open and render each page in a byte[] to OCRize them.
But I don't really understand what I need to set as rendered DPI.

            byte[] bytes = Engine.RenderPageToString(RenderedPdfDpi, pageIdx + 1, 0);

If I set 300 for example, and my pdf was in 96, I have a *3 zoom, which is very time consuming for my OCR. At the contrary, if I set 150 and my pdf was in 300, I have bad recognition results.

My PDF are simple multi pages images (like a TIF), so I thought about selecting the first image of each page, and reproduce the same DPI. But this do not work:
Engine.SelectPage(pageIdx + 1);
Engine.SelectImage(Engine.GetImageID(1));

Can somebody help me ?
Back to Top
moi meme View Drop Down
Beginner
Beginner


Joined: 22 Nov 10
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote moi meme Quote  Post ReplyReply Direct Link To This Post Posted: 09 Mar 11 at 2:24PM
Note:
To create the document, I simply load a PDF file with:
Engine.LoadFromFile(filename);
Back to Top
moi meme View Drop Down
Beginner
Beginner


Joined: 22 Nov 10
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote moi meme Quote  Post ReplyReply Direct Link To This Post Posted: 09 Mar 11 at 2:31PM
Hum... Now, the image selection works (I must have confused myself).
But I'm still unable to get the resolution of the image: ImageHorizontalResolution returns 0.

code:
Engine.LoadFromFile(filename);
Engine.SelectPage(pageIdx + 1);
int imgID = Engine.GetImageID(pageIdx + 1)
Engine.SelectImage(imgID);
int resH = Engine.ImageHorizontalResolution();
Back to Top
moi meme View Drop Down
Beginner
Beginner


Joined: 22 Nov 10
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote moi meme Quote  Post ReplyReply Direct Link To This Post Posted: 09 Mar 11 at 3:01PM
Ok I found :>
I only needed to set the right resolution to the rendered bitmap:


            RenderedPdfDpi = 300;
            byte[] bytes = Engine.RenderPageToString(RenderedPdfDpi, pageIdx + 1, 0);
            Bitmap bitmap = new Bitmap(new MemoryStream(bytes));
            bitmap.SetResolution(RenderedPdfDpi, RenderedPdfDpi);


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store