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!
![]() |
Render a page in a correct DPI |
Post Reply ![]() |
Author | |
moi meme ![]() Beginner ![]() Joined: 22 Nov 10 Status: Offline Points: 16 |
![]() ![]() ![]() ![]() ![]() 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 ? |
|
![]() |
|
moi meme ![]() Beginner ![]() Joined: 22 Nov 10 Status: Offline Points: 16 |
![]() ![]() ![]() ![]() ![]() |
Note:
To create the document, I simply load a PDF file with: Engine.LoadFromFile(filename); |
|
![]() |
|
moi meme ![]() Beginner ![]() Joined: 22 Nov 10 Status: Offline Points: 16 |
![]() ![]() ![]() ![]() ![]() |
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(); |
|
![]() |
|
moi meme ![]() Beginner ![]() Joined: 22 Nov 10 Status: Offline Points: 16 |
![]() ![]() ![]() ![]() ![]() |
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); |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store