Print Page | Close Window

LoadFromCanvasDC Question

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=1251
Printed Date: 27 Jan 26 at 2:20PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: LoadFromCanvasDC Question
Posted By: Syllus
Subject: LoadFromCanvasDC Question
Date Posted: 20 Oct 09 at 7:08PM
I am trying to create a HDC that can then have an image drawn on it through GDI commands (from one of our other applications) then pull that in as an image to be placed into a pdf creted with QuickPDF.  I saw http://www.quickpdf.org/forum/metafile-problem_topic1135_post5278.html?KW=loadfromcanvasdc#5278 - this post  where it was stated that the OP could use GetCanvasDC to get a DC handle, then use PlayEnhMetafile to draw a metafile's contents onto it, then use LoadFromCanvasDC to obtain a handle to a loaded image that could then be placed onto the PDF where ever needed.
 
This is the exact type of functionality I need with the exception of , I would use our drawing routines to draw the image to the DC instead of playing back a metafile.  What I do not understand, is how you get a loaded image from LoadFromCanvasDC(), or more specifically, a handle to a loaded image.  All that the actual LoadFromCanvasDC function seems to return is an integer representing a success or failure (0 or 1).  If this is in fact an accurate statement about obtaining a loaded image from LoadFromCanvasDC, and having a handle to it that can be used to draw it throughout the PDF, could anyone please explain to me how you get the loaded image and said handle? 

Currently whenever I try to make a call to LoadFromCanvasDC it seems like it recreates the whole PDF DOC as that image instead of giving me any kind of usable image that can then be placed.  As in, the entire PDF document then takes on the size and dimensions of the created DC during GetCanvasDC.
 
And of course if this is not the correct method to do something like this, any advice / nudge in the right direction would be greatly appreciated. 
 
Thanks in advance.



Replies:
Posted By: Syllus
Date Posted: 20 Oct 09 at 11:31PM
Ok, quick update,  after some more experimentation I found that by using the LoadFromCanvasDC() method it was actually adding a 2nd document to the instance of the PDF Library, by simply keeping a handle on the originl document I could then merge the 2nd document (drawing from the DC) and then capture the page, then i could use the DrawCapturedPage() method to draw the dc image where ever I wanted on the main document. (which was now the only document as the 2nd one was deleted as a by-product of the earlier operations).  I do not know if this is the intended method for this type of procedure, it is just what I have found that works so far... 
 
If there is a better way to bring in an image from a device context that was drawn directly to the DC by GDI commands, any nudges in the right direction are greatly appreciated. 
 
Again, thanks in advance.


Posted By: DELBEKE
Date Posted: 21 Oct 09 at 9:56AM
Hi Syllus, welcome here
 
Found in the help
 

GetCanvasDC

http://www.quickpdflibrary.com/help/quickpdf/VectorGraphics.php - Vector graphics , http://www.quickpdflibrary.com/help/quickpdf/DocumentManagement.php - Document management

Version history

This function was introduced in Quick PDF Library version 7.14.

Description

Creates a canvas of the specified size and returns a Windows device context DC that can be drawn on using Win32 drawing commands. When drawing operations are complete, call the http://www.quickpdflibrary.com/help/quickpdf/LoadFromCanvasDC.php - LoadFromCanvasDC function to create a new document from the supplied drawing commands.

The value is returned as a signed integer but should be cast to an unsigned integer HDC

 
Debenu is actualy working around this functions and the next release will have enhancements.


Posted By: Syllus
Date Posted: 21 Oct 09 at 3:08PM
Hey Delbeke, thanks for the reply.  Yes I am already doing this... I am currently using GetCanvasDC to create a DC which i then pass along to be drawn on by the win32 drawing commands of our other application, once that is done I use LoadFromCanvasDC... what I was expecting based on the other post I read was for that drawing to be then be loaded in as an image.
Quote At this momment , you have a handle on a loaded image you can draw anywhere in the pdf
However the questions arose once I realized that this was not the case and that it was in fact creating a new document.  It appeared at first as though it were replacing my old document. (this was before I realized that multiple documents could exist within a single instance of the PDFLib), once I realized that I started looking at the document management methods and experimenting with Doc merging, and page capturing, which seems to be working quite well at the moment.
 
It is looking like this library may be very well suited for our needs, another day of testing should show for sure.
 
Thanks :)


Posted By: DELBEKE
Date Posted: 22 Oct 09 at 7:01AM

There is an other way.

First you draw in an enhance metafile and save it to an emf file. Then you load the emf file with Qp.AddImageFromFile. Then, you can draw the image with Qp.DrawImage anywhere in your current document.
 
 
 
 



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