# Why is TeXWorks generating corrupted pdfs?

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?

-
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. –  Peter Grill Jan 24 '12 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 Jan 24 '12 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 Jan 24 '12 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. –  Peter Grill Jan 24 '12 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. –  Peter Grill Jan 24 '12 at 22:47

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.

-