5

I have installed MikTeX and TeXWorks on my Windows 7 PC.

When I edit a .tex file in TexWorks and then save the file as a pdf, the pdf created cannot be opened by Adobe Reader; Reader complains that the file is damaged.

Nonetheless, executing pdflatex myFile.tex on the windows command line creates a pdf that Adobe Reader can reliably open.

Why can't I create such pdfs through the TexWorks IDE?

6
  • 1
    Do you also have the .pdf file open in Acrobat Reader at the same time? Windows has several issues like this. Another example is that you can't always delete the .aux file unless you close the associated .tex file. Commented Jan 24, 2012 at 22:22
  • Thanks to both of you! Indeed, the play button worked. What does the "save as pdf" functionality do then? What use does it have?
    – David Faux
    Commented Jan 24, 2012 at 22:31
  • What 'Save as PDF' functionality? You can save as with a new name, but the file is still a plain text file.
    – Joseph Wright
    Commented Jan 24, 2012 at 22:41
  • @JosephWright: Indeed there appears to be a save as PDF functionality. I assume that is there since PDF files can be opened. Commented Jan 24, 2012 at 22:46
  • @percusse: You want to make that as an answer then. Might also mention what I said about having the PDF file open in another program. Commented Jan 24, 2012 at 22:47

2 Answers 2

6

The .pdf output of a TeX file is obtained after being compiled with one of the many compiling methods such as PDFTeX, PDFLatex, XeTeX etc. This is analogous to any other programming language, the source code cannot be saved as an .exe file to make it an executable.

In TeXworks one can use the play button to compile the .tex document with a compiler that can be set next to it.

However, as Peter Grill mentions, there are some peculiarities concerning the output and auxillary files during the source code compilation especially in Windows environment. The most common is experienced with Adobe Acrobat viewers. They do not let you to compile the same document if its output is already open in it since they lock the file for further modifications and TeX compilers complain and stop compiling. If this is a problem that should be addressed you can safely switch to another .pdf viewer such as SumatraPDF.

Another example is the removal of .aux files, as in some systems they are also locked and cannot be deleted even though they are not essential and can be reproduced.

These type of peculiar behavior tend to cause less and less annoyance when you get more experience with the machinary.

Happy TeX'ing.

1
  • I am experiencing problems opening with Adobe's reader using output from v 0.6.5 of TeXWorks on Windows 10, but an earlier version of TeXWorks on Windows 7 generates readable PDF's, including using the newest PDF reader from Adobe. I think there is more to this problem than file locking as Adobe's reader complains regardless of whether TeXWorks has been closed or not, .aux files deleted, etcetera. The PDF can be read in a browser window, but it is not an ok solution for me to not be able to open in Adobe's reader, for example if I want to send my PDF to someone who uses Adobe.
    – Circulwyrd
    Commented Nov 24, 2020 at 17:09
-1

Here is what worked for me (referencing my comment above to the accepted answer):

First, the problem was that the dictionary portion of the pdf format was corrupt or not present, which I discovered by using the excellent PDFDebugger tool from PDFBox (open source Java project).

While it would be more desirable to get it right in TeXWorks, what I found I could do as a workaround was, using the Brave browser, open it (which works) and then use Microsoft's PrintToPDF tool which is available in Brave (and presumably other browsers running on Windows, since it is a Microsoft tool).

After that, the PDF is saved correctly.

I am noting that there may be one circumstance in my case that could be causing this to happen for me, which is that my user name on Windows has non-latin characters in it. The corrupted dictionary entry seemed to be trying to reference a path containing these characters incorrectly which may have been what made it bomb. Either way, it is a bug in TeXWorks I think...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .