如何丰富右上角的文件名称

如何丰富右上角的文件名称

我包含了几个pdf名称类似这样的文件R1.pdf R2.pdf......R22.pdf 我需要打印姓名每个这样的文件的右上角每个所包含文件的页面。我的意思是,从第一页开始R0.pdf,每页的R0右上角都会用小写字母写上下一页R1.pdf R2.pdf等。

我怎样才能实现这个目标?顺便说一句,我很高兴能找到一个解决方案,在每个命令上方写一个新命令includepdf

\documentclass[landscape,a4paper]{article}
\usepackage{pdfpages}
\usepackage{pgfmath}
%\usepackage[margin=1cm,showframe]{geometry}% MWE only

\pgfmathsetmacro{\scale}{(\paperheight-2cm)/(\paperwidth-3cm)}% 1cm margin
\pgfmathsetlengthmacro{\delta}{\paperwidth-2cm-2*\scale*(\paperheight-3cm)-4mm}% 4mm fudge factor

\begin{document}

%  \includepdf[scale=1.02, nup=2x1,pages=1-8,trim=2.5cm 2.5cm 5.5cm 2.5cm]{sh1.pdf}


  \includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
  trim=2.5cm 2.5cm 5.5cm 2.5cm]{R0.pdf}


  \includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
  trim=2.5cm 2.5cm 5.5cm 2.5cm]{R1.pdf}

  \includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
  trim=2.5cm 2.5cm 5.5cm 2.5cm]{R2.pdf}

  \includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
  trim=2.5cm 2.5cm 5.5cm 2.5cm]{R3.pdf}

  \includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
  trim=2.5cm 2.5cm 5.5cm 2.5cm]{R4.pdf}

  \includepdf[scale=\scale,noautoscale,nup=2x1,pages=1-,delta={\delta} 0pt,offset=0pt -3mm,% offset in reverse order
  trim=2.5cm 2.5cm 5.5cm 2.5cm]{R5.pdf}
\end{document}

答案1

使用picturecommand如下选项:

\includepdf[
  pages=-,
  picturecommand={%
    \put(10,10){file.pdf}}
]{file.pdf}

选项picturecommand为您提供了图片环境,因此您可以自由地做任何您想做的事情,包括旋转东西:

\includepdf[
  pages=-,
  picturecommand={%
    \put(10,10){\rotatebox{45}{file.pdf}}}
]{file.pdf}

如果要打印 PDF 的标题,您必须先提取标题。使用 luatex 这并不难:

\newcommand\gettitle[1]{%
  \directlua{%
    local filename = kpse.find_file("#1", 'graphic/figure')
    doc = pdfe.open(filename)
    info = pdfe.getinfo(doc)
    title = info['Title']
    tex.print(title)
  }}

最后,在里面使用这个宏picturecommand

\includepdf[
  pages=1-2,
  picturecommand={%
    \put(10,10){\rotatebox{45}{\gettitle{file.pdf}}}}
]{file.pdf}

相关内容