I have a PDF file, containing a 3D object in PRC format. I try to include this into a LaTeX document to be compiled with pdflatex
, with the simple source below:
\documentclass{minimal}
\usepackage{graphicx}
\begin{document}
\includegraphics{LC.pdf}
\end{document}
Running pdflatex
(version 3.1415926-2.3-1.40.12, TeX Live 2011) over this does not yield any error or warning, but the PDF file created does not include the 3D content (in fact, it is empty). The log file for my compilation appears happy, however:
<LC.pdf, id=1, 200.74097pt x 196.72597pt>
File: LC.pdf Graphic file (type pdf)
<use LC.pdf>
Package pdftex.def Info: LC.pdf used on input line 4.
(pdftex.def) Requested size: 200.74046pt x 196.72548pt.
[1 <./LC.pdf>] (./a.aux) )
So: what am I doing wrong? How can I include this PDF figure, keeping its 3D content, into a LaTeX document?
Best Answer
As Martin said, interactive parts of a PDF, called Annotations in PDF specification parlance, such as links or 3D objects, get lost when embedding a PDF containing them. Instead, Annotations have to be re-generated for the new PDF.
To embed a 3D object in the PRC format into a PDF, use LaTeX package
media9
. Seemedia9
manual, section "3D quick-start guide".In case the standalone PRC file is not available it can be extracted from the PDF. This can be done manually, as explained below, or automatically with the help of a small Perl script. Either method requires a tool for uncompressing PDFs, such as PDFtk.
Automatically, using PDFtk + Perl script
This extracts all PRC streams from
PDFwithPRC.pdf
to separate filesprc-0.prc
,prc-1.prc
, ...On Windows, with a Java runtime and some
perl.exe
installed:Perl script
prcextract.pl
:Manual procedure, by PDFtk + text editor
First uncompress the PDF:
Open
doc.unc.pdf
in a text editor and scroll down to a line that starts withPRC
. This line appears just after a line with the PDF keywordstream
.Delete everything from begin of the file up to and including the line containing the
stream
keyword.Delete everything beginning with the line starting with the
endstream
keyword directly after the PRC stream upto the end of the file.Save what has left as a file whose name ends in
.prc
.