[Tex/LaTex] How to overcome Acrobat Reader error 131 with a pdfLaTeX doc

acrobaterrorspdftex

I'm generating a PDF document with pdflatex (more precisely, latexmk invoked from TexMaker 3.4. My LaTeX install is TeXLive 20120719). I can read the document fine in Okular and Gmail's attachment preview, but a colleague that runs Acrobat Reader on Windows reports: "There was a problem reading this document (131)".

EDIT: The error disappears when using \usepackage[demo]{graphicx}, which puts black boxes instead of the real images. They are all PDFs, PNGs and JPGs. Instead of using demo, I added the code for a \demoincludegraphics command, which makes the file work in Reader when using it to replace the logo in the headers, as shown below. But enabling it (using \includegraphics instead of \demoincludegraphics) and removing everything else also works in Reader! There is some strange global interaction that makes the file appear broken to Reader when enabling all the graphics…

My code compiles fine, reason why I only attach the preamble and a simple text for a Minimal Working Example:

\documentclass[12pt,lettersize,twoside]{article}

\usepackage[utf8]{inputenc}
\usepackage[spanish,es-tabla]{babel}  
\usepackage[fixlanguage]{babelbib}
\usepackage{amssymb,amsmath}
\usepackage{graphicx}   
\usepackage{array}   
\usepackage{caption}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{calc}
\usepackage{stfloats}
\usepackage{fixltx2e}
\usepackage{url}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=red]{hyperref}
\usepackage[all]{hypcap}

% Margins
\usepackage[top=2cm, bottom=2cm, left=3cm, right=2cm]{geometry}

% Make header show up in the first page
\makeatletter
\renewcommand\maketitle{\par
\begingroup
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
    \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
    \long\def\@makefntext##1{\parindent 1em\noindent
            \hb@xt@1.8em{%
                \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
    \if@twocolumn
    \ifnum \col@number=\@ne
        \@maketitle
    \else
        \twocolumn[\@maketitle]%
    \fi
    \else
    \newpage
    \global\@topnum\z@   % Prevents figures from going at top of page.
    \@maketitle
    \fi
    \thispagestyle{fancy}\@thanks % was {empty}
\endgroup
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}
\makeatother

% Remove date field in title; Remove preceding vertical space
\makeatletter
\renewcommand{\@maketitle}{
\vspace{-3cm}
\begin{center}%
{\LARGE \@title}\\
\vspace{2mm}%
{\@author}
\end{center}%
\par} \makeatother
\makeatletter

% Demo includegraphic boxes
\newcommand{\demoincludegraphics}[2][]{%
  \setlength{\fboxsep}{-\fboxrule}% Remove frame separator/gap
  \framebox{\rule{0pt}{100pt}\rule{150pt}{0pt}}% Framed box of 150pt x 100pt
}

% Headers Config 
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\headrulewidth}{0.4pt}
\setlength{\headheight}{2.2cm} 
\addtolength{\textheight}{-1.62cm}
\fancyhead[LO,RE]{\demoincludegraphics[height=1.6cm]{logo-slogan}}
\fancyhead[LE,RO]{}

% Footers Config
\fancyfoot{}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{\thepage}

% Notas al pie etiquetadas por simbolos  
\renewcommand{\thefootnote}{\fnsymbol{footnote}}

\title{Doc Title}
\author{My name}

\begin{document}

\maketitle

This is a test. It includes graphics and other floats.


\end{document}

EDIT: I found a workaround: Processing the generated pdf file through Ghostscript, as follows:

 gs -dSAFER -dBATCH -dNOPAUSE  -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

where input.pdf is the file generated by pdfLaTeX, and output.pdf the one that will be readable by Adobe Reader and the rest of the PDF readers.

Best Answer

I solved a similar problem by generating a PDF 1.4 only with pdflatex using \pdfminorversion=4. I'm also only using png's and 1.4 pdf images in my latex document. It worked before with evince but now acroread also reads the file just fine and I preserve the same quality level. The ghostscript workaround resampled my images to jpeg which derogated the quality.