🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.acrobat.sdk
11 messages
11 total messages Started by Steve_J_Willis Mon, 23 Mar 2009 15:15
Plugin with similar functionality to snapshot tool
#112
Author: Steve_J_Willis
Date: Mon, 23 Mar 2009 15:15
3 lines
1179 bytes
I would like to develop a plugin with functionality similar to the Acrobat snapshot tool. I'd like to provide a method for the user to select a rectangular region, and capture an image of that region to the clipboard, which is exactly what the snapshot tool does (I also want to add some features not provided by the snapshot tool once this is working). I've reviewed the SDK samples, and I'm not sure how to get started. Is this a special case of a Selection Server? Which API methods allow me to get the image of the rectangular selection, rather than iterating through PDF elements contained within?

Thanks!
Re: Plugin with similar functionality to snapshot tool
#117
Author: Leonard_Rosenthol
Date: Mon, 23 Mar 2009 21:33
1 lines
751 bytes
Your best bet is to render the page (or a portion of it) to an offscreen bitmap and then work from that.
Re: Plugin with similar functionality to snapshot tool
#119
Author: Steve_J_Willis
Date: Mon, 23 Mar 2009 22:35
11 lines
1435 bytes
Hi Leonard,

Thanks for the quick reply! Let me break down the areas I'm still unclear on into a couple of questions:

(1) What is the best way to allow the user to draw a rectangular selection? Are there some callback functions I should implement to allow the user to click and drag a marquee, or do I have to handle the code to draw the rectangle myself? I'm wondering, for example, if I need to implement the drawing code as part of a custom AVTool DoClickProcType callback, or if there is a better, built in way to get a rectangular area that a user has drawn (given that this operation is common to many tools).

(2) Once I have the rectangular selection coordinates from #1 above, how do I render it to an offscreen bitmap as you suggested? Is there a function in the API that allows me to do this?

Thanks again!

Steve
Re: Plugin with similar functionality to snapshot tool
#121
Author: Leonard_Rosenthol
Date: Tue, 24 Mar 2009 00:40
3 lines
787 bytes
Yes, custom AVTool with DoClickProc. There is an AV API that will handle the tracking for you (don't recall name offhand).

Look at the PDPageDrawXXX APIs for rendering to offscreen...
Re: Plugin with similar functionality to snapshot tool
#176
Author: Steve_J_Willis
Date: Wed, 01 Apr 2009 14:48
5 lines
1405 bytes
Thanks for the help! I have this working close to the way I need.

I am now using AVPageViewDragOutNewRect to allow the user to select a rectangular region, then AVPageViewDrawRectOutline to draw the outline of the user's selection to the screen. I want to allow the user to select multiple rectangular regions, perhaps on different pages. However, AVPageViewDrawRectOutline uses device space coordinates, so all selected rectangles are drawn on every page, regardless of the page they were originally selected from by the user. Is there a way to draw rectangular areas only on specific pages? These rectangles are supposed to be temporary and not a modification to the document, so I want to avoid annotations.

Steve
Re: Plugin with similar functionality to snapshot tool
#177
Author: Steve_J_Willis
Date: Wed, 01 Apr 2009 15:43
5 lines
1175 bytes
Never mind. I have determined that Acrobat will set the page number in the current AVPageView before drawing each page. In the callback function registered for page view drawing events, simply comparing the page number returned by AVPageViewGetPageNum with the page of the rectangle to be drawn appears to work correctly (if they are not equal, don't draw the shape). Of course, this means the original page number of each drawing needs to be saved along with the rectangle, which I am accomplishing using a vector of structs.

Thanks again for all the help to date!

Steve
Re: Plugin with similar functionality to snapshot tool
#181
Author: Steve_J_Willis
Date: Wed, 01 Apr 2009 18:07
5 lines
1026 bytes
I am having some issues implementing Leonard's suggestion above. It appears that PDPageDrawContentsToMemory() is only available from the PDF Library, not the standard Acrobat SDK. I'm trying to accomplish the equivalent of the built-in snapshot tool--that is, copy the image of a rectangular area on a page to the clipboard (or a jpeg, or whatever). Does the SDK provide any functions for accomplishing this?

Thanks!

Steve
Re: Plugin with similar functionality to snapshot tool
#182
Author: Leonard_Rosenthol
Date: Wed, 01 Apr 2009 19:25
1 lines
781 bytes
There are a set of PDPageDrawContentsXXX APIs that are available for plugins...
Re: Plugin with similar functionality to snapshot tool
#196
Author: Steve_J_Willis
Date: Thu, 02 Apr 2009 19:53
9 lines
1286 bytes
Thanks again for the help! I now have this nearly working.

I'm using PDPageDrawContentsToWindow to draw to an offscreen DC. This works fine. However, I want to limit what is drawn to the rectangle the user selected, which I store as an ASFixedRect. When I pass this to PDPageDrawContentsToWindow as the updateRect parameter, the entire page is still drawn with the same origin. I've also experimented with passing some invalid ASFixedRect values, and still the entire page is drawn. It seems like the updateRect parameter is being ignored (the default when this parameter is NULL).

Any advice?

Thanks!

Steve
Re: Plugin with similar functionality to snapshot tool
#199
Author: PDL
Date: Thu, 02 Apr 2009 20:36
1 lines
724 bytes
Are you sure you are passing the coordinates in rotated user-space and not device-space? Have you also tried PDPageDrawContentsToWindowEx?
Re: Plugin with similar functionality to snapshot tool
#200
Author: Steve_J_Willis
Date: Thu, 02 Apr 2009 20:50
7 lines
1286 bytes
The coordinates are certainly in user space, though I don't know what is meant by "rotated". The same ASFixedRect is also used to select text within the chosen area, and the selected text corresponds to the expected rectangular area. Even if my coordinates are wrong, I would expect only objects within the (incorrect) rectangle to be drawn per the documentation--not the entire page. As a test, I created an ASFixedRect with no dimension (zero for all values). Still, the entire page was drawn.

PDPageDrawContentsToWindowEx just calls PDPageDrawContentsToWindow, but allows control of the display flags. The result of calling this function is the same.

Any other thoughts?

Steve
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads