Print Page | Close Window

DC Resolution GetCanvasDC, GetCanvasDCEx

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3638
Printed Date: 22 Nov 24 at 7:53PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: DC Resolution GetCanvasDC, GetCanvasDCEx
Posted By: FOltean
Subject: DC Resolution GetCanvasDC, GetCanvasDCEx
Date Posted: 28 Nov 18 at 3:17PM
Hello everybody,

I use Delphi 2007 and RAD10.2.3 and QuickPDF 14.11.
The idea is to create PDF files by painting on the Canvas at a given resolution.

I tried the following:
First I used GetCanvasDC and the resolution is the screen resolution 96 DPI.
Then I used GetCanvasDCEx, provided the handle of a printer device context and the resultion is the same as the printer resolution 300 DPI.


if Printer <> nil then
      DC  := QP.GetCanvasDCEx(WidthPixels,
                              HeightPixels,
                              Printer.Canvas.Handle) //wil have the printer DPI (300)
else
      DC  := QP.GetCanvasDC(WidthPixels, 
                            HeightPixels) ; //will have the screen DPI (96)

But is it possible to set the DC resolution without "cheating" by using a printer DC ?

Thanks,

Florin O.







Replies:
Posted By: Ingo
Date Posted: 28 Nov 18 at 8:11PM
Hi Florin,

i don't know in detail what you're wanting but i've used the enhanced search function (above, on the right side here) with "printer DC canvas height" and found some search results.
Perhaps you'll find the neede information inside:

http://www.quickpdf.org/forum/forum_posts.asp?TID=2741&KW=printer+DC+canvas+height&PID=11246&title=metafile-to-pdf#11246

http://www.quickpdf.org/forum/forum_posts.asp?TID=2603&KW=printer+DC+canvas+height&PID=10742&title=problem-with-text#10742

http://www.quickpdf.org/forum/forum_posts.asp?TID=1921&KW=printer+DC+canvas+height&PID=8201&title=yellow-images-from-canvas-dc#8201

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: FOltean
Date Posted: 29 Nov 18 at 3:02PM
Hello Ingo and thank you for your answer.

>>I don't know in detail what you're wanting
I want to create PDF files having a resolution higher than 96 DPI.
As I said GetCanvasDC will return a DC having only 96 DPI, like the screen.
Using GetCanvasDCEx it is possible to have a higher resolution, but a printer has to be installed on the PC.
I would like to know if it is possible to specify the resolution when creating the CanvasDC.

Otherwise all works perfect for me, just that at 96 DPI the curves are not very nice.

Best regards,
Florin


Posted By: tfrost
Date Posted: 29 Nov 18 at 4:18PM
What I do is create a bitmap at whatever is the required resolution.  Then you can load or paint into it whatever you want.  If you want to keep your code really simple and clear, you can save the BMP to a stream, load the image from the stream using standard QPDF functions, and paint the image to the page using DrawImage or DrawScaledImage.  Otherwise you can play around at the device context level and perhaps save a millisecond or two and some memory, but I find that generally takes more research than I have time for to get the details exactly right and avoid memory leaks.  And most of the images I want to place on a page are already in file or stream format anyway.  Sometimes the higher-level functions make sense.


Posted By: FOltean
Date Posted: 10 Dec 18 at 10:14AM
Hi tfrost and thank you. 
I forgot to mention that I create vectorial PDF files, so drawing on a bitmap is not an option.
When using the default screen resolution of 96 DPI the curves are not very smooth.
But at 300 DPI (when I create a DC based on a printer DC) the curves are very nice.
Best regards



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