我需要PDF自动化,这是每张纸多个页面的变体。在这种情况下,我不需要一个简单的两页每页解决方案,这很容易。我需要将手写笔记并排到页面上。所以,在这里:
鉴于PDF格式,我希望每页打印两页,但一页必须为空白,如下所示:
module MailCheck
def check_mail
p "calls"
end
end
有没有人想要编写一个可以自动执行此操作的脚本?
PS。我知道如何在LaTeX中做到这一点,但我想避开大枪......
答案 0 :(得分:3)
如果避免使用LaTeX并不意味着避免使用依赖它的任何工具,那么PDFJam(Debian软件包是texlive-extra-utils)可能会有所帮助,请参阅q / a:Gluing (Imposition) PDF documents
否则你最好使用一个小脚本将.pdf文件页面转换为图像,然后将它们与空白图像合并,ImageMagick能够做到这些。
答案 1 :(得分:1)
使用Ubuntu:
# install packages
sudo apt-get install enscript ghostscript pdfjam pdftk
source="source.pdf"
output="output.pdf"
# create ps with one blank page
echo -n | enscript -p blank.ps
# convert p2 to pdf
ps2pdf blank.ps blank.pdf
# get number of pages of $source
num=$(pdftk "$source" dump_data | grep -Po 'NumberOfPages: \K.*')
# create string with new page numbers
for ((i=1;i<=$num;i++)); do pages="$pages A$i-$i B1-1"; done
# create pdf with white pages
pdftk A="$source" B=blank.pdf cat $pages output tmp.pdf
# create pdf with two pages on one side
pdfjam tmp.pdf --nup 2x1 --landscape --outfile "$output"
# clean up
rm blank.ps blank.pdf tmp.pdf
答案 2 :(得分:0)
我有一个解决方案,该解决方案不能完全打印所需的布局,而是打印横向表中居中的页面,如下所示:
+---+-------+----+
| | P.1 | |
| | | |
| | | |
+---+-------+----+
+---+-------+----+
| | P.2 | |
| | | |
| | | |
+---+-------+----+
如果您的目标是为手注释创建自由空间,则此布局可能会更好,因为它使您可以将注释写得更接近打印文本。
以下脚本依赖于pdfjam
,该脚本在后台使用LaTeX。可能为pdfjam
添加更多命令行参数将完全满足您的需求。
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "usage: $0 PDF_filename..."
echo
echo "This script takes a PDF file as command line arguments,"
echo "and generates a new, landscape-formatted PDF file, where every "
echo "page has very large margins which may be useful for editorial notes"
echo
echo "Requires: pdfjam, which is installed by the apt-get package texlive-extra-utils"
exit 1
fi
command -v pdfjam >/dev/null 2>&1 || { echo >&2 "I require pdfjam but it's not installed. Do an apt install of texlive-extra-utils to get it on Ubuntu. Aborting."; exit 1; }
pdfjam --batch --nup 1x1 --suffix widemargin --landscape "$@"