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 > General Discussion
  New Posts New Posts RSS Feed - Render PDF page does not match bitmap
  FAQ FAQ  Forum Search   Register Register  Login Login

Render PDF page does not match bitmap

 Post Reply Post Reply
Author
Message
Rene View Drop Down
Beginner
Beginner


Joined: 09 Oct 12
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rene Quote  Post ReplyReply Direct Link To This Post Topic: Render PDF page does not match bitmap
    Posted: 09 Oct 12 at 3:59PM
Hi all,
 
In have tried to render PDF to a bitmap, but this seems to be a quite sophisticated task. We want to render the PDF exact in a bitmap which size is calculated by PageWidth and PageWidth
 
For landscape formats I do not get exact results. Could depend on the fact that DPI is a long value and the calculated DPI is a rational number.
 
The code:
 
        wp = scaleX(PDF.PageWidth, vbPoints, vbPixels)
        hp = scaleY(PDF.PageHeight, vbPoints, vbPixels)
       
        ratioScreen = ScaleWidth / ScaleHeight
       
        Dim DPI_H As Long, DPI_V As Long, DPI As Long
       
        If wp > hp Then
            ratioPDF = wp / hp
            'Landscape
            w = ScaleWidth * mZoom
            h = ScaleHeight * (1 / ratioPDF) / (1 / ratioScreen) * mZoom
            pXOffset = 0
            pYOffset = (ScaleHeight * mZoom - h) / 2
            DPI = w / (PDF.PageWidth / 72)
        Else
            ratioPDF = wp / hp
            h = ScaleHeight * mZoom
            w = ScaleWidth * ratioPDF / ratioScreen * mZoom
            pXOffset = (ScaleWidth - w) / 2
            pYOffset = 0
            DPI = h / (PDF.PageHeight / 72)
        End If
       
        SetRect pbmpRect, 0, 0, w, h
       
        If Not pImg.gdiToken Then pImg.gdiToken = pImg.CreateGDIplusToken
        pImg.ManageOwnDC = True
           
        If pImg.Width = w And pImg.Height = h Then
            pImg.EraseDIB
        Else
            pImg.InitializeDIB w, h
        End If
           
        mDC = pImg.LoadDIBinDC(True)
           
        PDF.RenderPageToDC DPI, mPageIndex, mDC
 
What's going wrong? Any samples for perfect drawing results available?
Wouldn't it be better to get a function RenderToRect with parameters dc,page,x,y,w,h and DPI is calculated internally?
 
Cheers
 
René 

 
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