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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - LoadFromCanvasDC Question
  FAQ FAQ  Forum Search   Register Register  Login Login

LoadFromCanvasDC Question

 Post Reply Post Reply
Author
Message
Syllus View Drop Down
Beginner
Beginner


Joined: 19 Oct 09
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Syllus Quote  Post ReplyReply Direct Link To This Post Topic: LoadFromCanvasDC Question
    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 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.
Back to Top
Syllus View Drop Down
Beginner
Beginner


Joined: 19 Oct 09
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Syllus Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
DELBEKE View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 31 Oct 05
Location: France
Status: Offline
Points: 151
Post Options Post Options   Thanks (0) Thanks(0)   Quote DELBEKE Quote  Post ReplyReply Direct Link To This Post Posted: 21 Oct 09 at 9:56AM
Hi Syllus, welcome here
 
Found in the help
 

GetCanvasDC

Vector graphics, 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 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.


Edited by DELBEKE - 21 Oct 09 at 10:00AM
Back to Top
Syllus View Drop Down
Beginner
Beginner


Joined: 19 Oct 09
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Syllus Quote  Post ReplyReply Direct Link To This Post 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 :)


Edited by Syllus - 21 Oct 09 at 3:28PM
Back to Top
DELBEKE View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 31 Oct 05
Location: France
Status: Offline
Points: 151
Post Options Post Options   Thanks (0) Thanks(0)   Quote DELBEKE Quote  Post ReplyReply Direct Link To This Post 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.
 
 
 
 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store