Vim Tips Wiki
Line 30: Line 30:
 
There are also a few other DDE commands available with the Adobe Reader. Most interestingly, DocGoTo and DocGoToNameDest. The first can be used to jump to a particular page in the pdf while the second jumps to a named destination. I haven't figured out yet how to do so, but maybe one could use the second one to implement some sort of forward search with the Adobe Reader. (The idea is to call DocGoToNameDest with a fixed bookmark, say "cursorposition", and use latex to create that bookmark when compiling. Not sure if there exists some latex packet which could be used for that...)
 
There are also a few other DDE commands available with the Adobe Reader. Most interestingly, DocGoTo and DocGoToNameDest. The first can be used to jump to a particular page in the pdf while the second jumps to a named destination. I haven't figured out yet how to do so, but maybe one could use the second one to implement some sort of forward search with the Adobe Reader. (The idea is to call DocGoToNameDest with a fixed bookmark, say "cursorposition", and use latex to create that bookmark when compiling. Not sure if there exists some latex packet which could be used for that...)
   
Here is a little trick to open Adobe Reader on the last page. Just use DocGoTo with a large page number (which doesn't exist):
+
Here is a little trick to open Adobe Reader on the last page. Just use DocGoTo with a large page number (which doesn't need to exist):
 
!start cmcdde acroviewr10 control [DocOpen("%:p:r.pdf")][DocGoTo("%:p:r.pdf,10000")]
 
!start cmcdde acroviewr10 control [DocOpen("%:p:r.pdf")][DocGoTo("%:p:r.pdf,10000")]
 
[[Category:LaTeX]]
 
[[Category:LaTeX]]

Revision as of 21:57, 20 February 2011

When using Adobe Reader (on Windows) to view pdf files it will lock the current file. This makes it necessary to close the pdf file before recompiling a tex file into pdf. An easy way to do so is to use cmcdde.

To close the pdf output file of the currently edited tex file one would thus use:

 !start cmcdde acroviewr10 control [DocOpen("%:p:r.pdf")][DocClose("%:p:r.pdf")]

Here DocOpen registers the pdf with the dde server. DocClose then closes the pdf.

NOTE: The name Adobe uses for the DDE server changed from version 9 to 10. For Adobe Reader version prior to 10 use acroview instead of acroviewr10. Adobe also announced that future versions will continue to have the version number in the server name.

Automatically close pdf before compiling

I am using the vim-latex suite. To automatically close Adobe before recompiling using the suite I put the following in my tex.vim file:

 if has("win32")
   let s:AcroDDE = "cmcdde acroviewr10 control "
   let s:ClosePdf = s:AcroDDE.'[DocOpen("%:p:r.pdf")][DocClose("%:p:r.pdf")] '
   let g:Tex_CompileRule_pdf = s:ClosePdf.' & texify -bp --src $*'
   let g:Tex_ViewRule_pdf = 
           \ 'C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe'
 endif

NOTE: This configuration assumes that the folder containing cmcdde is in your path. Alternatively just specify the full path name to cmcdde in s:AcroDDE.


Comments

There are also a few other DDE commands available with the Adobe Reader. Most interestingly, DocGoTo and DocGoToNameDest. The first can be used to jump to a particular page in the pdf while the second jumps to a named destination. I haven't figured out yet how to do so, but maybe one could use the second one to implement some sort of forward search with the Adobe Reader. (The idea is to call DocGoToNameDest with a fixed bookmark, say "cursorposition", and use latex to create that bookmark when compiling. Not sure if there exists some latex packet which could be used for that...)

Here is a little trick to open Adobe Reader on the last page. Just use DocGoTo with a large page number (which doesn't need to exist):

 !start cmcdde acroviewr10 control [DocOpen("%:p:r.pdf")][DocGoTo("%:p:r.pdf,10000")]