SyntaxHighlighter

Wednesday, March 11, 2009

TexnicCenter DDE Commands for Acrobat Reader

Not really a dev related post, but I had to re-install Vista due to an epic fail on MS's part. My pc went into sleep mode and wrote the files from the C:\ProgramData\Microsoft directory to the C:\ProgramData\Microso~1 dir.

If this ever happens to you, I'm sorry to say you'll have to re-install your OS. I tried everything to get the files back to where they were supposed to be, but it looks like MS tightened security on FS and its impossible to move some of the Crypto files to where they belong. Even if you boot up in Linux...

Anyhow, I have to get latex running again and I'm using TexnicCenter as an editor. I forgot the DDE commands and had to figure it out again. Joy.

Here's the basic setup:
  1. In TexnicCenter, hit Alt+F7 and click on the viewer tab.
  2. In the "View project output" and "Forward search" options, select the "DDE Command" radio button and fill in the following: Command = [DocOpen("%bm.pdf")][FileOpen("%bm.pdf")], Server = acroview, Topic = control
  3. For the "Close document before running Latex" , select DDE with the same settings as above, but change the command to be [DocClose("%bm.pdf")]

One can also fool around with some other commands. Here's the snippet on DDE from the Adobe Interapplication Communication document:

Acrobat Application DDE Messages
This section lists all DDE messages. For complete descriptions of the parameters associated with DDE messages, see the DDE sections of the Acrobat Interapplication Communication Reference.

Application Configuration
  • AppExit — Exits Acrobat.
  • AppHide — Iconifies or hides Acrobat.
  • AppShow — Shows Acrobat.
  • CloseAllDocs — Closes all open documents.
  • HideToolbar — Hides the toolbar.
  • MenuitemExecute — Invokes a menu item, given its language-independent name.
  • ShowToolbar — Shows the toolbar.

Document Manipulation
  • DocClose — Closes the file without saving it and without prompting the user to save the document if it has been modified.
  • DocDeletePages — Deletes a specified range of pages in a document. It cannot delete all pages in a document.
  • DocInsertPages — Inserts specified pages from one file into another.
  • DocOpen — Opens a document and adds it to the list of documents known to DDE, allowing it to be manipulated by other DDE messages (for example, FileOpen).
  • DocReplacePages — Replaces specified pages using pages from another file.
  • DocSave — Saves the specified file.
  • DocSaveAs — Saves an open file into a new file, without warning the user if there is a problem saving.
  • DocSetViewMode — Controls whether bookmarks or thumbnail images are shown in addition to the document content.
  • FileOpen — Opens and displays a file, making it the current document and bringing it to the front if it is already open.
  • FileOpenEx — Opens and displays a file, making it the current document and bringing it to the front if it is already open. The file is opened during an idle loop to allow DDE messages to continue flowing during the opening of large documents.
Document Printing
  • DocPrint — Prints a specified range of pages from a document, without displaying a modal Print dialog box to the user.
  • FilePrint — Prints all pages in a document, displaying a modal Print dialog box to the user.
  • FilePrintEx — Prints all pages in a document, displaying a modal Print dialog box to the user. Only PostScript Level 1 operators are used for PostScript printing. Printing is performed during an idle loop to allow DDE messages to continue flowing during the printing of large documents.
  • FilePrintSilent — Prints all pages in a document, displaying no print dialog box to the user.
  • FilePrintSilentEx — Prints all pages in a document, displaying no print dialog box to the user. Only PostScript Level 1 operators are used for PostScript printing. Printing is performed during an idle loop to allow DDE messages to continue flowing during the printing of large documents.
  • FilePrintTo — Prints all pages in a document to a specified printer, using a specified driver and port, displaying a modal Print dialog box to the user.
  • FilePrintToEx — Prints all pages in a document to a specified printer, using a specified driver and port, displaying a modal Print dialog box to the user. Only PostScript Level 1 operators are used for PostScript printing. Printing is performed during an idle loop to allow DDE messages to continue flowing during the printing of large documents.
View Manipulation
  • DocGoTo — Goes to the specified page.
  • DocGoToNameDest — Goes to the specified name destination within the document.
  • DocPageDown — Scrolls forward through the document by one screen area.
  • DocPageLeft — Scrolls to the left by a small amount.
  • DocPageRight — Scrolls to the right by a small amount.
  • DocPageUp — Scrolls backward through the document by one screen area.
  • DocScrollTo — Scrolls the view of the current page to a specified location.
  • DocZoomTo — Sets the zoom for a specified document.
Search-related
  • DocFind — Finds a string in a specified file.

25 comments:

Anonymous said...

I have tried this suggestion with both Acrobat Reader 9 and Adobe Acrobad 8. Neither worked. Is there any other way around this very very anoying close-it-every-time-you-want-to-recompile problem?

Unknown said...

This should work. I use it on a daily basis. To recap, here's my settings:

In TeXnicCenter v1.0 do the following:
- Hit Alt+F7.
- Select the Latex => PDF Profile on the left.
- In the (La)TeX tab, check the "Run (La)TeX in this profile"
- Set the "Path to your (La)Tex compiler" to something like: C:\Program Files\MikTex2.7\miktex\bin\pdflatex.exe
- Set the "Command line arguments to pass to the compiler" to: -interaction=nonstopmode "%pm"
- If you're using Bibtex, set the path to something like: C:\Program Files\MikTex2.7\miktex\bin\bibtex.exe
- Set the bibtex command line arguments to: "%bm"
- If you're using Makeindex, set the path to something like: C:\Program Files\MiKTeX 2.7\miktex\bin\makeindex.exe
- And the command line args to: -s "%bm.ist" -t "%bm.glg" -o "%bm.gls" "%bm.glo"
- Select the Postprocessor tab. There shouldn't be any tasks, unless you require something specific to be done.
- Select the viewer tab.
- Set the "Path of executable" to something like: C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe
- In the "View project's output", select the "DDE Command" option.
- Enter this command (where 1 is the page you'd like the pdf document to open on): [DocOpen("%bm.pdf")][FileOpen("%bm.pdf")][DocGoTo("%bm.pdf", 1)]
- Set the "Server" value to: acroread
- Set "Topic" to: control
- Repeat the same values for the "Forward search" section.
- In the "Close the document before running (La)TeX", select the "DDE Command" option
- Set the command to: [DocClose("%bm.pdf")]
- Set the "Server" value to: acroread
- Set "Topic" to: control
- Click the "OK" button
- Click "Build" on the top menu and then "Select Output Profile"
- Be sure to select "LaTeX => PDF"
- Click "OK"
- Hit Alt+F5 to build the document

Anonymous said...

Thanks for the settings, they work perfectly with Adobe Acrobat Professional 8.0.

A side note: "C:\ProgramData\Microso~1" is the short version of "C:\ProgramData\Microsoft", it is pretty likely that you couldn't copy files between the directories because they are exactly the same directory. Some low level parts of windows give errors which seem to indicate files are missing while in reality they are corrupt. This seems more likely to happen when a system goes into sleep mode.

JP said...

I followed your directions Andre and this is what happened:

-TeXnicCenter immediately froze

-pdflatex.exe: GUI framework cannot be initialized.

Also, pdfTex/MikTex entered extended mode. I'm not sure that adds to the complication though.

alaelson said...

Hi!
The Andre's steps work with me. However, to do it, you just change the acroread parameter in DDE command -> server to acroview. I'm using Texniccenter 2.0 alpha and adobe reader 9.3

Unknown said...

@jp: Not sure what's wrong there. Try downloading the latest version of TeXnicCenter, MiTeX and Acrobat.

@Aleason: Thanks for the update. I've since finished my thesis and have stopped using TeXnicCenter

JP said...

@ Alaelson

I am using TexnicCenter 1.0 Stable Release Candidate 1.

I followed everything as proscribed, again.

If I turn off BibTex and MakeIndex, it works well. What a relief!

Is this strange?

Unknown said...

@jp: It seems a bit odd as both bibtex and makeindex have been around for ages and should be very stable; not causing texnicenter to crash. Well, if you're not using them, you should be good.

Unknown said...

@Alaelson: I've since reinstalled TexnicCenter RC 1, MikTex 2.8 and Acrobat 9.3 and I can confirm that the acroread parameter should not be used. Please use acroview.

Amir said...

Thanks for the detailed instructions.

- I tried the configurations (preset with server parameter = acroview and acroread) with Adobe Reader X, and the TexnicCenter froze both times.

- I uninstalled the Reader, and installed an older 9.4 version. TexnicCenter works smoothly with configuration parameter, server = acroview.

Unknown said...

@Amir. Thanks for the contribution. Haven't tried Acrobat Reader X yet

Anonymous said...

If you use Adobe Reader X, you will have to rename the server to acroviewR10. If you work with Adobe Acrobat, try acroviewA10! Harry

Unknown said...

Shot Harry!

Anonymous said...

Thanks a lot Andre. The settings for Acrobat 1ß was exactly what I was looking for.

Anonymous said...

Worked for me! Thanks Andre!

Anonymous said...

worked for me too, thanks a lot :)

JorgeRO said...

acroviewR10 worked for me using Acrobat Reader X. Thanks!

Anonymous said...

Thanks a lot. Have been trying to achieve this for hours now...

Anonymous said...

Great! Same problem, and found this after an hour of searching. I have Adobe Reader XI now, so I tried to put acroviewR11 in there, and it worked! (MiKTeX 2.9)

Anonymous said...

Many thanks :) This helped a lot and is working fine on my setup (Texnic Center 2.0 and Adobe Reader 9.0)

Anonymous said...

Thanks anonymous. Setting server to acroviewR10 worked (TexnicCenter 1.0src1, adobe reader X, win xp)

N3kr0manc3r said...

Thank you very much! your description was accurate.

One little thing - is there anyway that instead of specifying a fixed page number in the DocGoTo command I can have it so that the current line in which I am writing in Texniccenter is where the document in Adobe reader will open at on compilation?

Unknown said...

I searched long and hard for a way to jump to the position where one's currently typing, but was unable to find a solution.

usman said...

Adobe acrobat reader
nice post :) Thanks alot.

Floran said...

Very nice post. However, it seems that the DocSave and DocSaveAs command are not working properly.

[DocOpen("%bm.pdf")][FileOpen("%bm.pdf")][DocSave("%bm.pdf")]

entered in both Project output and Forward Search return an error with acroviewR20