These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Comment toolbar not available in embedded Acrob. Pro 9 thru OLE Atmt

zmin2001
Registered: Oct 30 2009
Posts: 12

Hi,

We have an application hosting Acrobat Pro 9 thru OLE automation. We want to use the stamping feature in the embedded Acrobat Pro 9. However, the Comment and Markup toolbar is not available in the embedded Acrobat although it's available in the standalone Acrobat Pro 9.

We used to be able to enable stamping feature (comment and markup toolbar) in our application with Acrobat Pro 7. What we did was to set up collaboration using Reviewing and Collaboration options of Acrobat. However, we can’t find the place to enable them in 9.1 (Edit > Preferences > Reviewing > Shared Review Preferences doesn’t seem to work).

Can anyone advise what we need to do to make Comment and Markup toolbar available in the embedded Acrobat Pro 9?

Thanks,
Min

My Product Information:
Acrobat Pro 9.1.3, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You've got a couple of options, you could create your own toobar button that runs the stamp menu item. But you'd need to add this menu item to the white list in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Adobe Acrobat\8.0\FeatureLockDown\cDefaultExecMenuItems

But the easiest thing to do is place this line of code in a document level script.
Collab.showAnnotToolsWhenNoCollab = true;
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

zmin2001
Registered: Oct 30 2009
Posts: 12
Thank you for your information.

I actually tried the option 2 but it doesn't seem to work in my case. What I did is to add Collab.showAnnotToolsWhenNoCollab = true; to the sdkAddSignature.js from Acrobat SDK and put it in the JavaScript directory. After that, I can see the Add My Signature menu is added in standalone Acrobat (assuming the script is loaded and run when Acrobat is started). However, the Comment & Markup toolbar is still not available in our application hosting Acrobat through automation.Did I miss anything or this doesn't work in an "embeded" Acrobat?

Thanks,
Min
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Try putting the code in a document level script so that it is run in the document context when the PDF is loaded into the viewer.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

zmin2001
Registered: Oct 30 2009
Posts: 12
Thanks for your prompt response.

How can we add a document level script to the document our application is to open? We have millions of pdf documents. it's not possible to add the document level script statically. I'm looking into adding the script dynamically in our application before opening the report but it's not straight forward because our application is written in C++.

Do you know any easier way we can achieve this (without going thru C++->JavaScript "bridge")?Thanks,
Min
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You could use an FDF file to place the Doc Script. You can form the URL to the PDF so that it includes a reference to the FDF. The Acrobat merges the FDF at the same time it loads the PDF. But you know. I'd have to do some testing to see if this is really possible. I'm not totally sure of the operation. My general idea though is that you need to run this code in the context of the document in the external viewer (i.e. the ActiveX module).

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

zmin2001
Registered: Oct 30 2009
Posts: 12
Our application doesn't use Acrobat Forms nor communicate with web servers. It open opens PDF files converted from MS Word from file locations. I'm not sure how FDF can be used in this scenoris.

I'll try to use SDK API to add the script and see how it works.

Thanks,
Min
zmin2001
Registered: Oct 30 2009
Posts: 12
I have managed to make the comment & markup toolbar available in our application by using SDK API to call javascript "Collab.showAnnotToolsWhenNoCollab = true;". However, I can't find a way to programatically show the toolbar thru automation. All the discussions about toolbar in the documentation seem to be for plugin only. Is there any way I can show the toolbar without having to create a plugin?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are a set of menu items, under the View menu for toggling the toolbars on and off. The comment bar is called "ShowHideToolbarCommenting". From JavaScript, displaying a specific toolbar is a two step process.

1. Use the app.listToolbarButtons() function to find out if the specific toolbar is displayed.
2. Then use the menu item to display that toolbar.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

zmin2001
Registered: Oct 30 2009
Posts: 12
It worked. Thank you for your help.
zmin2001
Registered: Oct 30 2009
Posts: 12
Hi,

Our code stopped working. It happened after our system admin installed a security patch. Now, we are even not able to get the form.fields interface (to call javascript). It throws an exception "No document is currently open in the Acrobat Viewer". I suspect it's to do with the security patch but don't know exactly what. Our system admin is unable to revert the changes.

Does anyone have clues?

Thanks,
Min
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Security restrictions are getting more draconian all the time:( But there may be a way around it. Can you identify the exact line of code that's causing the exception and the context?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

zmin2001
Registered: Oct 30 2009
Posts: 12
Yes, it throws exception at FormObj.GetFields. It's called immediately after a document is opened with OpenInWindowEx. I'm sure there is a document in the viewer as it worked fine before. I just suspect some environment changes make Acrobat not be able to get the opened document at the moment when the GetFields is called.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Seems like the connection is lost in the new window. This is odd because your using the AVDoc to open the window. Should be a solid connection. However, the error you reported has just started to popup in other situations. So the new security stuff is probably blocking all kinds of stuff. Greater sandboxing I guess.

I'd suggest a different approach. I don't know what it is that you are doing with the fields. But I've found it's much better to do any complex document manipulation in JavaScript, if possible. Write a Folder Level Function for whatever it is you want to do. Since you are starting off with the AVDoc you can easily get the PDDoc and then the JSO. Just run your function from the JSO. It will automatically run in the context of the document.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

hotpelmen
Registered: Apr 2 2010
Posts: 18
Hi, I tried to implement thomp's advice from 2009-12-08 18:11:47, but it does not seem to work with comment-enabled PDF loaded into the browser window.

My code goes through the list of TreeItem's generated by app.listToolbarButtons() as well as through the list of their children and checks if any of them have cName matching "CommentTask". If none is found then it does the following:

Collab.showAnnotToolsWhenNoCollab = true;
app.execMenuItem("ShowHideToolbarCommenting");

The result is as follows: "Comment" dropdown shows up, but the actual toolbar containing the commentint tools ("Sticky Note", "Text Edits" etc.) does not. User can make it show through that "Comment" dwopdown I mentioned ("Show Comment&Markup Toolbar" option) but my goal is to make it show automatically, docked or undocked does not matter.I inserted an app.alert statement in front of the first statement and I can see the "Comment" dropdown showing up after I close the alert pop-up. But the second line does not seem to do anything.

Since the app.execMenuItem line toggles that toolbar on/off, I tried commenting it out thinking that maybe it toggles the commenting toolbar "off", but the result is the same. Only the "Comment" dropdown shows up.

However, if I add app.execMenuItem("ShowHideToolbarCommenting"); to a javascript button
app.addToolButton({
...
cExec: "try{app.execMenuItem(\"ShowHideToolbarCommenting\")}catch(e){}",
...
});

then it works: the entire commenting toolbar is popping up (toggling, actually).

Can you tell me why it works when the user clicks the button, but it does not make any difference when it is within the main body of javascript right after "Collab.showAnnotToolsWhenNoCollab = true;", which I know makes the difference.

Thank you!!!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Sounds like a timing issue. Try delaying the execution of the menu item with app.setTimeOut();

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

hotpelmen
Registered: Apr 2 2010
Posts: 18
Hi Thom,

I appreciate your prompt reply.

Using app.setTimeOut does not seem to help. Here's what I did (hope formatting will be preserved):

----------
function toggleCommentsToolbar () {
try{
// app.alert("before");
app.execMenuItem("ShowHideToolbarCommenting");
// app.alert("after");
} catch (e) {
app.alert(e);
}
}

Collab.showAnnotToolsWhenNoCollab = true;
var toggler = app.setTimeOut("toggleCommentsToolbar()", 699); // why 699 - see item 4 below
//app.clearTimeOut(toggler);
-----------

Here are my observations:

1. When comment-enabled PDF opens in the browser, commenting toolbar does not pop up. "Comment" dropdown shows up OK.

2. I tried putting both "app.execMenuItem(\"ShowHideToolbarCommenting\")" and "toggleCommentsToolbar()" as the first argument. Same result in both cases.

3. When I used "toggleCommentsToolbar()" with app.alert() statements uncommented within the function, the "before" and "after" popped up as expected, so the app.execMenuItem was undoubtedly invoked, but the commenting toolbar did not show;

4. For some reason, putting any value >=700 seems to break the delay mechanism, so maximum value I could plug in is 699. Therefore the maximum delay I can plug in is only a little over half-a-second. But it is observable, and should be enough one would think. Still not sure where this limitation comes from.5. I also tried putting app.clearTimeOut() statement at the very end, but it seems to break the delay mechanism.

Any advice on other possible causes of the commenting toolbar not showing will be greatly appreciated!

Thank you!!!
hotpelmen
Registered: Apr 2 2010
Posts: 18
I played with the code placing various alert statements before and after key code statements and it looks like the problem is that this line of code

Collab.showAnnotToolsWhenNoCollab = true;

does not take effect until the ENTIRE body of javascript finishes executing, and that includes the second statement, app.execMenuItem("ShowHideToolbarCommenting") invoked with or without app.setTimeOut().

Looks like app.setTimeOut() forks a new process, but the Reader waits for it to finish before "committing" the change to Collab.showAnnotToolsWhenNoCollab.

This explains why the button can do it and javascript running "on-open" cannot.

So the question is if there is some way to "commit" the change to the Collab.showAnnotToolsWhenNoCollab property within javascript code itself. I will keep digging. Any ideas?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How about placeing the menu item execution somewhere else? for example a page open script. There might also be something you can do with a field script, maybe a calc script. I'm sure there are other options for taking the menu execution out of the document script.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

hotpelmen
Registered: Apr 2 2010
Posts: 18
Hi Thom,

Thanks for your advice. Tried adding JS code that uses setPageAction for page 0 and Open trigger, and tried adding JS code that adds a form field with OnFocus action set to execute the menu item and then sets focus on it. In both cases, since I can only embed non-privileged JS code, I get 'NotAllowedError' thrown.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
How are you adding code to the PDf?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

hotpelmen
Registered: Apr 2 2010
Posts: 18
Please note that I clarified the previous comment. All the attempts I made were implemented within the JS code.

We assemble the pdf using a LiveCycle ES2 process we created. In that process, a PDF Assembler component uses DDX to put together source PDF, JS code and XFDF, and a Usage Rights component does comment enabling.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You have an odd situation. It would have been useful to know about this up front. I don't know very much about how the servers operate with respect to adding elements, particularly code, into a PDF.

So you can't add a page open script directly? I would suggest that you manually build the PDF with Acrobat Pro to figure out what configurations will work, and then figure out how the servers can be used to create that configuration.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

hotpelmen
Registered: Apr 2 2010
Posts: 18
That's a good idea, thank you.
vidhya k p
Registered: Aug 9 2011
Posts: 1
Hi,

TypeWriter Icon is missingwhen I laod Acrobat Pro 9.0.0 through my application mPDDoc = (Acrobat.CAcroPDDoc)mAVDoc.GetPDDoc();

avDoc.OpenInWindowEx(pdfPath, hwnd.ToInt32(), 1, 1, 0, 1, 2, 0, 0, 0);

Iam opening acrobat pdf thru these lines of code. But Typewriter icon is not visible. Can you please help me with this