![]() |
| Adobe Forums » Software Discussions » Adobe Acrobat » Adobe SDK and Programming » using browser javascript to copy selectedtext from a pdf file opened in Air app. |
| Tags: |
![]() |
| LinkBack | Thread Tools | Display Modes |
|
|||
|
I have posted this question on reader forum as well, but I think it is more suited here...
I am trying to create a note-taking application in air. I want to extract selected text from pdf file as a string object or to the clipboard. Obviously, all pdfs in my local storage will not be scripted to recieve postMessages and act accordingly, and that is not practical either. So, my problem is, how can I copy the selected text in the pdf file (opened as an object in htmlloader within my Air app) to clipboard or directly in another control by say clicking a button in air application? I suppose, this is possible using javascript, however, I don't know which reader methods are exposed to the wrapper htmlloader control. In short, I want to execute app.execMenuItem("Copy") command through htmlloader javascript. Any alternate solutions are also welcome. This is similar to passing inbuilt commands/methods/functions (of adobe reader) to pdf-reader plugin embedded in a webpage via javascript. This is possible in IE where the pdf is rendered as activex object, and hence JSObject interface of pdf document/reader is accessible to the browser javascript. I have also read that this same JSObject is accessible to VB as interface for IAC, so as the Air is Adobe's own product, I was wondering if equivalent of JSObject is accessible to htmlloader control as well. Thanks in advance... Mits |
|
|||
|
From the documentation for the IAC, the interface for the browser ActiveX object is the AxAcroPDFLib.AxAcroPDF object. Maybe all the methods aren't listed, but what is documented does not show any methods for actually getting any info out of the PDF. It seems that without an explict HostContainer message handler in the PDF there is no way to get the selection out of the PDF.
This really is expected behavior. Acrobat has a pretty strong security model and doesn't allow communication between different contexts unless the user specifically allows it or there is some kind of special setup between the contexts, like the Host Container. And even that communication link can be blocked by browser security. Thom Parker WindJack Solutions The source for PDF Scripting Info pdfscripting.com <http://www.pdfScripting.com> The Acrobat JavaScript Reference, Use it Early and Often <http://www.adobe.com/devnet/acrobat/javascript.html> |
|
|||
|
Since you're doing an AIR app you have some level of control over the user's system, i.e., you could get them to install an Acrobat or IE plug-in. Maybe a folder level script would work. The trick of course is to get a handle on functionality that's not normally availible to the browser interface. This is brand new territory.
Executing a copy to clipboard seems pretty simple. The thing is, I'm not sure exactly how you would activate it in Acrobat from Actionscript in an AIR app. From a privileged JavaScript context you can run this line of code: app.execMenuItem("Copy"); Both an Acrobat plug-in and the IAC have similar functionality. If you are running IE in windows it's possible that you could write a VB add-in to the browser that could use the IAC. If AIR could use a .NET component you might be able to use the IAC directly. But I'm just not sure. Ideally you want clean and direct interface. I just don't think one exists. There is one other possibility, the DDE interface. This is an acient message passing system from the Windows 3.1 days. The IAC reference still lists the DDE interface, but I haven't used it since Windows 98. I don't know if it still works. I'm at a loss, Good Luck, Thom Parker WindJack Solutions The source for PDF Scripting Info pdfscripting.com <http://www.pdfScripting.com> The Acrobat JavaScript Reference, Use it Early and Often <http://www.adobe.com/devnet/acrobat/javascript.html> |
|
|||
|
Hi Thom,
I appreciate your concern. I think you are exactly getting what I mean. As you can see, the problem is, I am working on an Air app. However, the very advantage of writing air app, of it being platform independent would get lost if I write a win or mac plugin. Or, I'll have to write two plugins, just for executing the copy command, one for each, mac & win, and still, linux wont be covered, else all of my peers wont be able to use it. Another way is to reproduce all my pdfs in a batch mode, adding a doc/folder level javascript function, which is possible but not practical for adding a simple copy function. What I don't understand though is that, why would adobe not expose reader methods through a Javascript interface to it's own Air api, when it is available for other programming platforms, especially the methods which adobe itself considers safe, like those in edit and view menus? Thank you nevertheless. Mitesh |
![]() |
| Thread Tools | |
| Display Modes | |
|
|