Generalclosing documents when using Foxit

General information and discussion about TeXnicCenter
evencoil
Posts: 9
Joined: Sun Dec 02, 2007 11:28 pm

closing documents when using Foxit

Post by evencoil »

I've started using FoxIt instead of Acrobat (a great improvement!) and got it to work fine in TeXniccenter except I haven't figured out a way to have the document automatically be closed before I open it again. I'm thinking this might not be possible since FoxIt doesn't have DDE support, but does anyone know for sure? Any ideas for a workaround? thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

ben16
Posts: 2
Joined: Tue Dec 18, 2007 2:46 pm

Re: closing documents when using Foxit

Post by ben16 »

Hello, (excuse my english ...)
you can try the autohotkey script :

loop ,%1%
{
IfWinExist, %A_LoopFileName%
WinClose ; use the window found above
}
Run,%1%

compile the script
copy the .exe in a folder (C:\Program Files\CloseFoxit)
and call it instead foxit
in Texnicenter Build>outputprofile>viewer
path of executable : C:\Program Files\CloseFoxit\CloseFoxit.exe
command line argument : %bm

I join the compiled script

Best regards
Flominator
Posts: 3
Joined: Wed Nov 07, 2007 8:30 pm

closing documents when using Foxit

Post by Flominator »

Nice idea. Thanks. Maybe my solution inspired by yours helps, too.
evencoil
Posts: 9
Joined: Sun Dec 02, 2007 11:28 pm

closing documents when using Foxit

Post by evencoil »

Success! :o

First of all, thanks for the hints. Things didn't go all that smoothly, of course, but who would expect that? :)

Here are the problems I remember, in approximate order...

1. "taskkill" is a windows XP command. If you use Windows 2000 (like me) then the appropriate command is simply "kill".

2. The command "kill" is not included with a typical install of Windows 2000...It's pretty easy to install from your Windows 2000 cd. See http://seer.entsupport.symantec.com/docs/253904.htm

3. The filename of the Foxit Reader executable is "Foxit Reader.exe"...I think the old batch system doesn't like filenames like that or something, because I had a devilish time trying to reference it. Luckily, Foxit is a self-contained program so I just changed the filename to the very friendly "foxit.exe".

4. Since I often have .pdf articles open as well as the .pdf for the .tex file I am working on, I want the kill command to search out the right .pdf file to close.

So anyways, here's my solution:

In TexnicCenter Output Profile:
path of executible: "C:\Foxit Reader\foxit_close.bat"
view project output command line argument: "%bm.pdf" %tm
(the quotes like that are important)
forward search command line argument: [empty]
close document before running (La)tex: Do Not Close


And my foxit_close.bat file:

Code: Select all

KILL %2*
START "C:\Foxit Reader\foxit.exe" %1
The only subtlety is passing %tm, which is the "title" of the Latex document, as parameter %2. If you are using Foxit and your file is foo.pdf then the window title will look something like "foo.pdf - Foxit Reader 2.2 - [foo.pdf]". So if you, like me, name your files the same as your titles in your latex documents then you are in business since the title, %tm, will be "foo" and KILL %2* will kill any window that starts with "foo"....Not foolproof, but works with the least amount of effort. Might have to think of something more clever later.

Anyway, thanks again for the helpful suggestions...hopefully with our three solutions anybody else coming across this problem will have enough to work with 8)
daniloz
Posts: 1
Joined: Wed Apr 30, 2008 2:14 pm

closing documents when using Foxit

Post by daniloz »

Thanks a lot ben16, it works just great !

Cheers,
Wrzlprmft
Posts: 1
Joined: Wed Jan 06, 2010 2:42 pm

closing documents when using Foxit

Post by Wrzlprmft »

Using Windows XP I did almost the same as evencoil:
In TexnicCenter Output Profile:
path of executible: "C:\Foxit Reader\foxit_close.bat"
view project output command line argument: "%bm.pdf" %tm
(the quotes like that are important)
forward search command line argument: [empty]
close document before running (La)tex: Do Not Close
However I needed to use a different foxit_close.bat for Windows XP:

Code: Select all

taskkill /fi "Windowtitle eq %2*" /im Foxit*
sleep 0.5
START "C:\Foxit Reader\Foxit Reader.exe" %1
Because I like to use Foxit's feature to remember the view settings, I do not kill it forcefully. This takes some time however, which is why I added the sleep command. Otherwise the new window would be opened before the old one is closed. Depending on your system you might want to vary the sleep time (the number behind sleep).

If you do not care about the aforementioned feature, the following foxit_close.bat is sufficient:

Code: Select all

taskkill /f /fi "Windowtitle eq %2*" /im Foxit*
START "C:\Foxit Reader\Foxit Reader.exe" %1
jennyshred
Posts: 1
Joined: Tue Mar 16, 2010 9:28 pm

Re: closing documents when using Foxit

Post by jennyshred »

An autohotkey script could be a best thing to use on that kind of documents setting. Using the Foxit could not be so easy for me, because I've not been using it often.
spiegboy
Posts: 120
Joined: Thu Dec 06, 2007 9:58 am

Re: closing documents when using Foxit

Post by spiegboy »

use acrobat reader
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

closing documents when using Foxit

Post by frabjous »

spiegboy wrote:use acrobat reader
Yes, use if you want to waste lots of system resources unnecessarily.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

closing documents when using Foxit

Post by localghost »

spiegboy wrote:use acrobat reader
The Adobe Reader in its versions >=8 has turned out to be not the ideal partner for TeXnicCenter (TXC). It locks opened files and so prevents them from being updated after an additional LaTeX run. Although it can close files before the next run, it doesn't reload automatically. Furthermore it doesn't support SyncTeX for synchronization between source code and PDF output. A much better viewer for use with LaTeX and especially TXC is SumatraPDF. The current alpha version of TXC2 recognizes if it is already installed on the system and automatically generates an according output profile.
Post Reply