Render a page in a correct DPI  
       
      Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
        Category:  For Users of the Library
       Forum Name:  I need help - I can help
       Forum Description:  Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
       URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1763
       Printed Date: 04 Nov 25 at 12:02PM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
      
 
  
      Topic: Render a page in a correct DPI
       
      Posted By: moi meme
       Subject: Render a page in a correct DPI
       Date 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 ? 
          | 
         
        
      
 
  Replies: 
       
      Posted By: moi meme
       
      Date Posted: 09 Mar 11 at 2:24PM
       
      
        
          
	
Note: To create the document, I simply load a PDF file with: Engine.LoadFromFile(filename); 
          | 
         
        
        
       
      
      Posted By: moi meme
       
      Date 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(); 
          | 
         
        
        
       
      
      Posted By: moi meme
       
      Date 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);
 
  
          | 
         
        
        
       
      
     |