# Which hyperref variable can I set to make a pdf open with the “Comment” tool displayed in the right panel of the window?

We are using Adobe Acrobat X when viewing our pdf files produced by pdflatex and the hyperref package. To make the commenting process more intuitive for users not familiar with Adobe Acrobat X, I want the pdf to automatically open with the Comment tool displayed on the right hand side of the document, as shown in the illustration below. Is that possible? Can I set some hyperref variable to accomplish that?

-
I'm pretty sure Acrobat does not have such a feature, unless perhaps via javascript –  Lev Bishop Sep 16 '12 at 6:34

Unlike bookmarks or thumbnails, there is AFAIK no setting in the PDF catalog for comment tools. But JavaScript seems to allow this, see JavaScript for Acrobat API Reference.

The following example adds a JavaScript action, when the document is opened. The example is written for pdflatex/lualatex and assumes hyperref is loaded (but the latter is not needed).

Perhaps the menu item "SaveHideToolbarCommenting" toggles the commenting tools view. Therefore I have also added a bookmark that calls this menu item.

The example file:

\documentclass{article}
\usepackage{hyperref}

% disable hyperref's openaction
\hypersetup{pdfstartpage={}}
% set JavaScript openaction
\pdfcatalog{}openaction user{%
<<%
/S/JavaScript%
/JS(%
)%
>>%
}\relax

\usepackage[atend]{bookmark}
\bookmarksetup{
open,
numbered,
}
\BookmarkAtEnd{% or \AtBeginDocument
\bookmark[
startatroot,
level=0,
italic,
rawaction={%
/S/JavaScript%
/JS(%
)%
},
]{Toggle Comment Tool}%
}

\begin{document}
\section{Hello World}
\end{document}


Edit: The menu item string can also be used in named actions, that simplifies the example and JavaScript is not needed:

\documentclass{article}
\usepackage{hyperref}

% disabe hyperref's openaction
\hypersetup{pdfstartpage={}}
% set JavaScript openaction
\pdfcatalog{}openaction user{%
<<%
/S/Named%
/N/ShowHideToolbarCommenting%
>>%
}\relax

\usepackage[atend]{bookmark}
\bookmarksetup{
open,
numbered,
}
\BookmarkAtEnd{% or \AtBeginDocument
\bookmark[
startatroot,
level=0,
italic,
named=ShowHideToolbarCommenting,
]{Toggle Comment Tool}%
}

\begin{document}
\section{Hello World}
\newpage
\section{Second Page}
\end{document}


Unhappily the action "ShowHideToolbarCommenting" does open the commenting sidebar for the OP. In the PDF catalog object preferences for showing bookmarks, thumbnails or open content groups can be configured to some degree, but commenting is not part of this.

-
Thanks a lot for your contribution and code! But I am not sure your code meets my needs. It makes a button for toggling the commenting side-window, but such a button already exists ("Commenting"). Apart form that, the pdf file produced behaves strange. When clickin it, a "Save as" dialog box opens. When saved and opened, clicking your bookmark "Toggle Comment Tool" results in a warning dialog box, with a white cross on a red button, saying: "Warning: JavaScript Window -" ShowHideToolbarCommenting. And nothing happens. :( –  Espen Donali Sep 19 '12 at 13:59
Sorry, wrong example file, it had used other actions to test for Adobe Reader. I fixed the answer. –  Heiko Oberdiek Sep 19 '12 at 14:05
Hi, now the code works without the strange behaviour mentioned above (the "Save as" and Warning dialog boxes). But pressing the button you made (the bookmark "Toggle Comment Tool") does not result in anything. But most important, and as mentioned in my former comment: I am not sure your code meets my needs. It makes a button for toggling the commenting side-window, but such a button already exists ( the "Commenting" option on the right upper side of the pdf-window, see figure above). I want my pdf to opened with the commenting sidebar in open position. –  Espen Donali Sep 20 '12 at 8:27