# Fatal error, "Can't write on file 'test.pdf' [closed]

I am not the most experienced latex user, so I hope I can describe the problem accurately. When I compile my tex document I get following message:

! I can't write on file test.pdf'. Please type another file name for output

! Emergency stop.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox
\fi \fi
l.1 \begin{titlepage}


I run Windows 7 if it helps and I use following packages.

\documentclass[a4paper,10pt]{report}
\usepackage{hyperref}
\usepackage{amsthm}
\usepackage{cleveref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{pdfpages}
\usepackage{appendix}
\usepackage{import}

• Do you have the PDF open in Adobe Acrobat or another PDF reader? – darthbith Apr 10 '14 at 11:07
• Welcome to TeX.SX! Do you have your PDF file opened in Adobe Reader, perhaps, when you try to compile? – karlkoeller Apr 10 '14 at 11:07
• Note that not all readers lock the .pdf. Foxit used not to (which was my main reason for using it) but now does. – Chris H Apr 10 '14 at 11:08
• @darthbith as does evince on linux (though it lacks some nice features of other readers). On windows I use a compile batch file that causes foxit to open a new tab with the latest compile in it - good for comparing output when tweaking - but now it has to muck about with renaming files: tex.stackexchange.com/a/126205/28808 – Chris H Apr 10 '14 at 11:11
• A few more things to try then: delete the .pdf; delete all other generated files (.aux etc); check the permissions on the folder (is it for example a network location, or some similar case where your permissions could have changed?); copy test.tex to test2.tex and compile that; copy to c:\temp or equivalent and compile there. – Chris H Apr 10 '14 at 11:14

I have been having a similar problem. It is related to the pdf getting locked by Adobe Reader. Once Adobe opens the file, the compile error occurs. I delete the files (like the questioner), and compile works, but the error returns when I open it again in Adobe. I don't think the [g], as Martin Schroder suggests, was the solution.

!!NOTICE!! I worked out the problem. I haven't got a single clue to why this leads to conflict but.. In my introduction I have a table/tabular and in the first cell, first line I wrote "[g]" for indicating gram as a unit.

\begin{table}
\centering
\caption{Recipes for initial experiments}
\begin{tabular}{lcc}
\toprule
[g]& 5$\%$ cement sub. & 10$\%$ sand sub.\\
\midrule
Water & 225 & 275\\
Sand & 1350 & 1215\\
Cement & 427.5 & 450\\
Ash & 22.5 & 135\\
\bottomrule
\label{opskrift}
\end{tabular}
\end{table}


This apparently causes the error, since the error doesn't appear when I just write "$[g]$".

 \begin{table}
\centering
\caption{Recipes for initial experiments}
\begin{tabular}{lcc}
\toprule
$[g]$& 5$\%$ cement sub. & 10$\%$ sand sub.\\
\midrule
Water & 225 & 275\\
Sand & 1350 & 1215\\
Cement & 427.5 & 450\\
Ash & 22.5 & 135\\
\bottomrule
\label{opskrift}
\end{tabular}
\end{table}
`

Note that I must delete all generated files before compiling again. The error will keep showing if the generated files are not deleted. :-) Thank you guys for your assistance.