Print Page | Close Window

Mimic Adobe's Fit Page, Fit Visible, Fit Width

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=1604
Printed Date: 06 May 25 at 12:11PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Mimic Adobe's Fit Page, Fit Visible, Fit Width
Posted By: RedOctober
Subject: Mimic Adobe's Fit Page, Fit Visible, Fit Width
Date Posted: 14 Oct 10 at 3:48PM
I'm new to QuickPDF Library.  I'm also new to these forums.  I didn't realize that there are several different forums for Quick PDF Library.  I guess I posted in the wrong one yesterday because when I returned here today, my question is no where to be seen.  So here goes again...

Development Environment:  Delphi 7, XP Pro,  Quick PDF Library 0721

I've examined the example:  QPLDelphiDemo.exe
In the source code for the "View/Print" tab there is a "RenderPage" procedure that displays one page of a .Pdf, zoomed to a multiple of 25.  I can get this working properly.  However, I want to give my user's the same zoom options as what Adobe Reader has, including the "Named" zoom values of

Actual Size, Fit Page, Fit Visible, Fit Width

How do I do the calculations so that TQuickPDF will draw it to the correct zoom?  I also noticed that every zoom selection is multiplied by 96.  What is significant about the number 96?

Thanks in advance for any help you can provide, and please let me know if I've double posted, cross posted, or what forum I should be using for asking questions about QuickPDF Library.  Thanks.



Replies:
Posted By: Rowan
Date Posted: 20 Oct 10 at 9:53AM
Adjusting the zoom for rendered PDF files (and thus Actual Size, Fit Page, Fit Visible, Fit Width) is not the simplest of tasks. I'll try to explain.

If you have a 100 pixel x 100 pixel image and you draw it into a 100mm x 100mm area on the page the result will be an image with a DPI of 25.4.

If you want to have a 1 image pixel to 1 screen pixel mapping at 100% zoom in Acrobat or another PDF viewer then the image needs to be drawn at 72 DPI.

For a 100 pixel image to be shown with a 1:1 pixel mapping at 100% zoom needs to be drawn at (100 / 72) x 25.4 = 35.278mm.

It does depend on the PDF viewer. If the user changes their DPI settings then there isn't anything the PDF creator can do to know that.

For example, in Adobe Reader 9, Edit / Preferences / Page Display, I have the DPI set to 110 on my system by running in "Large screen fonts" mode in Windows when I installed Adobe Reader. However, any value can be selected here.

Essentially, there is no way to force the user to view the bitmaps on a page at a certain zoom level.

So the pixel size of an image really isn't useful when doing layout. You just specify the size in mm (or whatever the page measurement units is set to) and the image will appear in that area regardless of the number of pixels.

In the code sample that you looked at the DPI was 96 instead of 72, but it could have been 110 or another number as well. To determine the width and height of the rendered PDF you could also take into account the page width and page height of the page in the PDF to determine how big an image placeholder you should generate in your application for the PDF.


Posted By: RedOctober
Date Posted: 20 Oct 10 at 2:05PM
Thank you Rowan.  I think I'm starting to understand, not to get too hung up about pixels (just because the sample code was based on pixels).  However in your response you say:

"You just specify the size in mm (or whatever the page measurement units is set to) and the image will appear in that area regardless of the number of pixels."

What is the page rendering command I can use to accomplish what you say in the quoted statement?  Thanks in advance.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk