保存影像可見性

保存影像可見性

我寫了一個包含多行文字欄位和三張圖片的文件。如果單擊,圖片會改變可見性。但是,如果在查看 PDF 時更改了圖片的可見性,然後儲存文檔,則圖片變更不會儲存到文件中。對文字欄位的變更將被儲存。

如何保存圖片可見狀態?

\documentclass{scrartcl}
\usepackage{ocgx}
\usepackage{tikz}
\usepackage{hyperref}

\begin{document}
\begin{frame}

\begin{Form}
\TextField[multiline=true,width=\linewidth,height=50pt,value=Exampletext]{}
\end{Form}

\begin{tikzpicture}
\node at (0,0) {\begin{ocg}{Image 1}{ocg1}{1}\actionsocg{ocg1}{}{}{\includegraphics[width=1.0cm]{example-image-a}}\end{ocg}};
\node at (0,1) {\begin{ocg}{Image 2}{ocg2}{1}\actionsocg{ocg2}{}{}{\includegraphics[width=1.0cm]{example-image-b}}\end{ocg}};
\node at (0,2) {\begin{ocg}{Image 3}{ocg3}{1}\actionsocg{ocg3}{}{}{\includegraphics[width=1.0cm]{example-image-c}}\end{ocg}};
\end{tikzpicture}

\end{frame}
\end{document}

答案1

訣竅是

  • 在圖片上方繪製複選框
  • 設定背景顏色透明
  • 設定顏色白色
  • 刪除邊框
  • 將符號設定為矩形
  • 放大字體,使符號填滿整個框
  • 設定大小與圖片相同
  • 從複選框中刪除標籤

需要最新的 hyperref 套件。

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{hyperref}

\begin{document}

\begin{Form}
\TextField[multiline=true,width=\linewidth,height=50pt,value=Exampletext]{}

\begin{tikzpicture}
% get rid of label space
\def\LayoutCheckField#1#2{\makebox#2}

\node at (0,0) {\includegraphics[width=1cm,height=0.7cm]{example-image-a}};
\node at (0,0) {
  \CheckBox[
    borderwidth=1,
    backgroundcolor=,
    color=1 1 1,
    bordercolor=,
    checkboxsymbol=\ding{110},
    charsize=100pt,
    checked=false,
    width=1cm,
    height=0.7cm
  ]{}
};  

\node at (0,1) {\includegraphics[width=1cm,height=0.7cm]{example-image-b}};
\node at (0,1) {
  \CheckBox[
    borderwidth=1,
    backgroundcolor=,
    color=1 1 1,
    bordercolor=,
    checkboxsymbol=\ding{110},
    charsize=100pt,
    checked=false,
    width=1cm,
    height=0.7cm
  ]{}
};  

\node at (0,2) {\includegraphics[width=1cm,height=0.7cm]{example-image-c}};
\node at (0,2) {
  \CheckBox[
    borderwidth=1,
    backgroundcolor=,
    color=1 1 1,
    bordercolor=,
    checkboxsymbol=\ding{110},
    charsize=100pt,
    checked=false,
    width=1cm,
    height=0.7cm
  ]{}
};  

\end{tikzpicture}

\end{Form}

\end{document}

相關內容