将封面图像添加到现有 pdf 文件会破坏原始 pdf 的链接

将封面图像添加到现有 pdf 文件会破坏原始 pdf 的链接

我们有一个 main.pdf、一个封面图片和一个 tex 文件。当我们使用 texlive2013 在主 pdf 中添加封面图片和 tex 文件的内容时,主 pdf 中的链接会中断,也就是说,链接文本仍然以蓝色显示,但它们不再指向任何内容,它们只是普通文本。

tex 文件的内容:

\documentclass[a4paper,11pt]{article}
\usepackage{times,color,graphicx}
\usepackage[final]{pdfpages}
\renewcommand\familydefault{\sfdefault}
\definecolor{covergray}{gray}{0.5}
\usepackage[pdftex,%
  pdfstartview=FitH,%
  bookmarks=false,%
  colorlinks=true,%
  urlcolor=covergray%
]{hyperref}

\begin{document}

\thispagestyle{empty}%
\setcounter{page}{1}
\parindent=0pt\parskip=0.5pc

\begin{center}\bf
\vfill
\begin{center}
  \frame{\includegraphics[height=1.0\hsize]{cover.jpg}}
\end{center}
\vfill
\color{covergray}
Some text
\href{http://www.google.com}{http://www.google.com}
\end{center}
\includepdf[pages=-]{main.pdf}
\end{document}

答案1

据我所知,所有可以包含 PDF 图像的 TeX 驱动程序都会从​​页面(包括链接)中删除注释。

解决方法:

  • 如果是main.pdf通过 TeX 生成的,那么最好的策略就是在那里添加封面以保留链接和轮廓main.pdf

  • 有一个项目pax(PdfAnnotExtractor)它使用 Java 库PDFBox(旧版本)提取一些注释,然后将其插入 LaTeX 包中\includegraphics(由 使用pdfpages)。

  • PDFtk可以保留一些注释:

    pdftk cover.pdf main.pdf cat output new.pdf
    

    但轮廓main.pdf已经消失。

相关内容