Scenario: I am generating pdf using FPDI from php , where I use a template pdf to
fill the form (its static not Fillable) ,I place text in required positions to
give the feeling of its filled by user. which is working great except size it little
extra than expected and pdf are viewable without any error or issues
New Requirement: Now I need to
- merge these files into single file
- create a bookmark to each report generated in first step (create TOC)
- possibility reset the page numbers
Obviously I need an open source tool , I don't find any opensource lib/tool( php /java/commandline ), so I installed MacTex package for pdflatex and realted tool
Whenever I include the pdf generated from php I get the errors below . My question to this great community is how I can fix this issue and what are the chances of merging the pdf files generated from php and add TOC
I have borrowed the tex file from SE by @captaincomic
Tex
\documentclass[8pt]{article}
\usepackage[final]{pdfpages}
\usepackage{fancyhdr}
\topmargin 70pt
\oddsidemargin 150pt
\pagestyle{fancy}
\rfoot{\Large\thepage}
\cfoot{}
\renewcommand {\headrulewidth}{0pt}
\renewcommand {\footrulewidth}{0pt}
\begin{document}
\includepdfset{pagecommand=\thispagestyle{fancy}}
\includepdf[pages=-]{include_file.pdf}
\end{document}
> pdflatex number.tex
Output Error
....
<include_file.pdf, id=3, page=1, 614.295pt x 794.97pt>
<use include_file.pdf, page 1> <use include_file.pdf, page 1>
<use include_file.pdf, page 1> <use include_file.pdf, page 1>
<use include_file.pdf, page 1> [1{/usr/local/texlive/2011/texmf-var/fonts/map/p
dftex/updmap/pdftex.map} <./include_file.pdfError (2874915): Bad 'Length' attribute in stream
!pdfTeX error: pdflatex (file ./include_file.pdf): PDF inclusion: type <error>
cannot be copied
==> Fatal error occurred, no output PDF file produced!
Best Answer
I successfully repaired
include_file.pdf
using the command line toolpdftk
:or command line tool
qpdf
:Both tools recompress all stream objects within a PDF file, thereby renewing the value of the
/Length
entry in the associated stream dictionary of the stream object.qpdf
reports wrong\Length
values in 12 stream objects.With the fixed file the error disappears.