Print Page | Close Window

Problem Rendering PDF w/ Windows Scale is not 100%

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=3901
Printed Date: 20 Apr 24 at 4:55AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Problem Rendering PDF w/ Windows Scale is not 100%
Posted By: waynefulcher
Subject: Problem Rendering PDF w/ Windows Scale is not 100%
Date Posted: 02 Mar 21 at 10:54PM
I am using Delphi 7 and the QuickPDF Library (version 16.13).
In my code I am calling the RenderPageToFile() method.
I have tested this with many different parameters but the combination that I can not get to work correctly just happens to be the only option I actually need.

So if I render the page passing in the Option/Format as 8 (EMF+) it works perfectly fine, UNLESS you right-click your windows desktop and select Display Settings and then change your scale to something other than 100%. I tested with 150%. Then when rendering as EMF+ the content on the page is not correctly scaled. So for example if the PDF has a paragraph of text that basically goes from side to side of a letter size page then if Windows Scale is 150% and page is rendered as EMF+ then the text shrinks to only about half the width of the page.

If I test other formats, such as 1 (JPEG) then it seems to still scale the content on the page correctly even when Windows scale is at 150%.

Anyone have any idea how I might be able to fix this?

Thanks



Replies:
Posted By: tfrost
Date Posted: 03 Mar 21 at 10:58AM
Rendering to EMF is a problem because EMF seems to always need a reference DPI from a printer or screen, as you have found. However you should be able to simply check the screen DPI before rendering, and adjust the DPI when you render. Things get more complicated when you have screens of different resolutions in use, especially if the window has been moved from one to another, or if you are writing a service application without a window. The DPI of the primary monitor may be the one you want, but experimentation and testing are essential.

Using one of the other renderers supported by QPDF may also help (see SelectRenderer in the documentation).  However this involves distributing an extra DLL with your application. And note that DPLPDFIUM may not be thread-safe.


Posted By: waynefulcher
Date Posted: 03 Mar 21 at 4:28PM
Thanks for your feed back I will look into the SelectRenderer to see if that can provide any help.
But as to the comment about DPI, that is not exactly how that works. The DPI and Scale is slightly two different things. For example in the call to RenderPageToFile() it has a DPI parameter which I pass in, I have tested with many different values and the only difference it makes is how clear the results are and the size of the output. So 60 is blurry but the size is very small (not visually), 150 dpi is a good balance between clarity but not too big in size then as you try 300 or 600 the clarity gets slightly improved but the size of the output is very large.

The problem is the scale of the rendering to the size of the page. So something in rendering must be using one DPI for the width/height of the page and something different for the content.


The issue here actually seems to be a Windows issue and whatever GDI+ driver that is installed with windows. In searching I have read about many other applications having the same sort of problem with Scale (not DPI). Oddly enough Microsoft used to supply a checkbox to correct the issue in their display settings back in Windows 7 but that checkbox does not exists in Windows 10. So I guess I will try to see if windows has a fix for Windows 10 or if I can somehow use a different renderer but that seems like any other renderer will also rely on the GDI+ libraries installed on the computer which most likely means they probably all will have the same issue.

If I find a solution I will come back and post it for other to use.
Thanks again.






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