如何使我的整个文档适合单个 PDF 页面?

如何使我的整个文档适合单个 PDF 页面?

我有一个相当长的文档,通常显示为两页。现在,我想生成单页 PDF 文档。换句话说,我想要一个 A4x2 大小的 PDF。你会怎么做?

编译后可以这样做:https://stackoverflow.com/questions/2507766/merge-convert-multiple-pdf-files-into-one-pdf

答案1

为了说明我的评论:

\documentclass{standalone}
\usepackage{graphicx}

\newcommand{\pages}{6}% number of pages
\newcommand{\filename}{pecha.pdf}% filename of document

\newcounter{pdfpage}
\newsavebox{\tempbox}
\savebox{\tempbox}{\includegraphics[page=1]{\filename}}% get width of document

\begin{document}
\begin{minipage}{\wd\tempbox}
\loop\ifnum\value{pdfpage}<\pages\relax
  \stepcounter{pdfpage}%
  \includegraphics[page=\thepdfpage]{\filename}\par
\repeat
\end{minipage}
\end{document}

答案2

这是一个更简单的解决方案,不需要对两个单独的文档进行两次单独的编译:

  1. 在寄出每一页时进行截取,
  2. 将其添加到盒子中并
  3. 在文件末尾发货。

包裹艾特贝格使第一步变得非常容易,第二步可以用普通(简单)原语来处理。

% PACKAGE CODE

\RequirePackage{atbegshi}
\RequirePackage{luatex85}

\newbox \fulldocument

\AtBeginShipout{%
    \global\setbox\fulldocument=\vbox\bgroup
        % previous pages
        \unvbox\fulldocument
        % a line between pages
        \hrule width \pdfpagewidth
        % the current page
        \vbox to \pdfpageheight\bgroup
            % we have to position it like tex does
            \vskip \dimexpr \pdfvorigin + \voffset
            \moveright \dimexpr \pdfhorigin + \hoffset
                \box\AtBeginShipoutBox
            \vss \egroup
    \egroup \AtBeginShipoutDiscard}

\AtEndDocument{\par\break
    % spacing has already been applied manually
    \pdfhorigin = 0pt
    \pdfvorigin = 0pt
    \hoffset = 0pt
    \voffset = 0pt
    % set the new page height
    \pdfpageheight = \ht\fulldocument
    % output the full page
    \AtBeginShipoutOriginalShipout
        \box\fulldocument}

% DOCUMENT CODE

\documentclass{article}

\begin{document}

Page 1
\newpage
Page 2
\newpage
Page 3

\end{document}

相关内容