11

I want to avoid to recompile large tikz graphics and therefore I compile them as a standalone pdf file. This file contains some OCG layers which I want to use in the main file, but the OCG layer are ignored in the main file.

OCG file (ocg-pdf.pdf):

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{ocgx}

\begin{document}
    \begin{tikzpicture}
        \begin{scope}[ocg={name=Layer1,ref=l1,status=visible}]
                \filldraw[color=red] (0,0) rectangle (1,1);
        \end{scope}
        \begin{scope}[ocg={name=Layer2,ref=l2,status=visible}]
                \filldraw[color=blue] (2,2) rectangle (3,3);
        \end{scope}
    \end{tikzpicture}
\end{document}    

Main file:

\documentclass{scrartcl}

\usepackage{graphicx}

\begin{document}
    \includegraphics{ocg-pdf}
\end{document}

Has anyone an idea?

  • Welcome to TeX.SX! This may have nothing to do with TikZ at all. Does a generalized PDF with OCGs retain its "OCG-ness" when included using \includegraphics? (Sorry, I have no time to test myself at the moment.) – Paul Gessler Oct 27 '14 at 14:49
  • Right in general this does not work with includegraphics. I have tested this for example with (http://acroeng.adobe.com/Test_Files/OCG//CADSample.pdf) – Grandement Oct 27 '14 at 15:09
  • May not be technicaly related but it reminds me of this limitation: http://tex.stackexchange.com/questions/14620/how-to-preserve-hyperlinks-in-included-pdf – alfC Oct 28 '14 at 07:07

1 Answers1

10

There is currently no way to do this with standard pdfTeX/XeTeX/LuaTeX, as there is no way to wire the OCGs in the included PDFs with the OCGs in the including document (this may be doable with the new PDF library in LuaTeX, though - but nobody has done that yet).

I solved this some years ago in a version of pdfTeX available here; there is some documentation on this here.

That version is not maintained anymore and the work has not been incorporated into any stable engine, though.