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 PDF page does not match bitmap |
Post Reply |
Author | |
Rene
Beginner Joined: 09 Oct 12 Status: Offline Points: 1 |
Post Options
Thanks(0)
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é |
|
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