我编写了一个包含多行文本字段和三张图片的文档。单击图片时,图片的可见性会发生变化。但是,如果在查看 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
诀窍是
- 在图片上方绘制 CheckBox
- 设置背景颜色透明
- 设置颜色白色
- 删除边框
- 将符号设置为矩形
- 放大字体,使符号填满整个框
- 设置尺寸与图片相同
- 从复选框中删除标签
需要最新的 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}