I am doing a forest plot and want to save it to a PDF file.
My forest plot is oversize (8in*20in). It can fit in a one page PDF like this:
dev.print(pdf, file="C:\\Work\\plot.pdf", width=8, height=20);
But then it is too long: When I print this PDF on a A4 paper, it has to be shrinked to fit the paper.
So I want to save it to a two-page PDF file (from R). Ps: it is not a question about how to set the printer.
How to do this?
So, you are able to generate an 8in x 20in == 203.2mm x 508mm == 576pt x 1440pt
sized PDF showing a plot.
It is not entirely clear to me from your question what exactly you want:
Sorry, I cannot help here...
If you print a PDF from Adobe Acrobat or from Adobe Reader, then you'll find a setting in the print dialog named "Poster". Here you can select to print one PDF page across multiple pieces of paper. (It also lets you select if you want some overlap from piece to piece, and if you want to add cut marks and the like to the printouts).
MuPDF is a lightweight PDF (and other document formats) viewer, made by the same company that also maintains Ghostscript. MuPDF ships with an additional command line utility, mutool
.
Its subcommand poster
can divide PDF pages into smaller tiles and 'posterize' them. So this command will achieve what you want:
mutool poster -x 1 -y 2 input.pdf output.pdf
The output.pdf
will be divided into 1 part (i.e. not divided) in x-, and into 2 equal parts in y-direction. (You could divide it into any other number of segments if you wanted). So output.pdf
will have two pages, each sized 8in x 10in
. A4 paper is sized 8.26in x 11.69in
when measured in Inches.
When printing these, you'll still need to enable the Print to fit Page Size
checkbox in the print dialog if you want to make best use of the A4 page size.
Ghostscript is a command line tool that can (amongst many other functions) be used to process PDF files (PDF in, modified PDF out). It can be (ab)used to cut PDF pages into halfs.
Here are a few previous StackOverflow answers which describe how to do it. You'll need to adapt some parameters to your specific size(s), but the principles should be clear from those examples (even though some of these split pages into left and right halves, not top/bottom as you may require):
The method described there is more tedious and not as straight-forward as with the mutool poster
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With