开发者

Clone PDF file in a single page

I've got a PDF file which is exactly 1/5 of the size of an A4开发者_JAVA百科 page, and a script to convert it into a single A4 page by appending it repeatedly. The problem is that ImageMagick only works with bitmap graphics, and my PDF contains text and detailed vector graphics. The result is therefore loss of text data, much bigger file size, and worse print output.

I'd like to be able to do the same as the line convert -density 1200 $pdf_file $pdf_file $pdf_file $pdf_file $pdf_file +append $a4_file without rasterising the vector graphics.


pdftk and pdfnup are really most excellent!

Pseudocode version of the finished script:

for each file:
    inkscape --export-pdf
    pdftk (pdf-file x 5) cat output 5.pdf
    pdfnup 5.pdf --nup 5x1 --paper a4paper --orient landscape --outfile {recto,verso}.pdf

pdftk R=recto.pdf V=verso.pdf cat R1W V1E output bookmark.pdf


OK, I've an idea how this could work, but I don't have the possibility to test it at the moment.

Now consider these three commands (would need Unix-ification if you're not on Windows):

 gswin32c ^
    -sDEVICE=pdfwrite ^
    -o p1.pdf ^
    -dFIXEDMEDIA ^
    -sDEFAULTPAPERSIZE=a4 ^
    -r600x600 ^
    -dDEVICEWIDTHPOINTS=842 ^
    -dDEVICEHEIGHTPOINTS=595 ^
    -c "<</PageOffset [0 0]>> setpagedevice" ^
    -f c:/path/to/first.pdf

 gswin32c ^
    -sDEVICE=pdfwrite ^
    -o p2.pdf ^
    -dFIXEDMEDIA ^
    -sDEFAULTPAPERSIZE=a4 ^
    -r600x600 ^
    -dDEVICEWIDTHPOINTS=842 ^
    -dDEVICEHEIGHTPOINTS=595 ^
    -c "<</PageOffset [168.4 0]>> setpagedevice" ^
    -f c:/path/to/second.pdf

 gswin32c ^
    -sDEVICE=pdfwrite ^
    -o p3.pdf ^
    -dFIXEDMEDIA ^
    -sDEFAULTPAPERSIZE=a4 ^
    -r600x600 ^
    -dDEVICEWIDTHPOINTS=842 ^
    -dDEVICEHEIGHTPOINTS=595 ^
    -c "<</PageOffset [336.8 0]>> setpagedevice" ^
    -f c:/path/to/third.pdf

Barring any mis-calculation on my part, these "print" your first 3 PDFs onto an A4 landscape medium, but shifting the page offset for each one by 'n*(1/5 of the landscape width)' points, starting with n=0. (A4 is 842x595 points). You get the idea...

Now you'll have 3 (and later: 5) new PDF files without any additional bitmap graphics.

Your job remains now to use pdftk (which you seem familiar with) to overlay these 3 (5) PDF pages over each other.

Please give some feedback if this works for you. (And don't let the Black Hole escape :-) ).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜