Adobe Forums

Add Me
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:



Reply
LinkBack Thread Tools Display Modes
using browser javascript to copy selectedtext from a pdf file opened in Air app.
  #1 (permalink)  
Old 11-30-2008, 06:42 AM
mitesh_patel@adobeforums.com
Guest
 
Posts: n/a
Default using browser javascript to copy selectedtext from a pdf file opened in Air app.

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


Reply With Quote


  #2 (permalink)  
Old 11-30-2008, 06:42 AM
Thom_Parker@adobeforums.com
Guest
 
Posts: n/a
Default Re: using browser javascript to copy selectedtext from a pdf file opened in Air app.

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>
Reply With Quote


  #3 (permalink)  
Old 12-02-2008, 07:06 AM
Thom_Parker@adobeforums.com
Guest
 
Posts: n/a
Default Re: using browser javascript to copy selectedtext from a pdf file opened in Air app.

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>
Reply With Quote


  #4 (permalink)  
Old 12-02-2008, 07:06 AM
mitesh_patel@adobeforums.com
Guest
 
Posts: n/a
Default Re: using browser javascript to copy selectedtext from a pdf file opened in Air app.

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
Reply With Quote


Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Hairstyles | UFO Videos | Bollywood Wallpapers | Poems  | WWE


All times are GMT. The time now is 10:29 PM.
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.