6

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?

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
Yukun
  • 315
  • 4
  • 15
  • @KurtPfeifle I don't know if I am wrong but this cannot make the graph landscape – Yukun Apr 07 '15 at 17:10
  • @ Dirk Eddelbuettel I already checked the question, it is NOT the same as my question. Mine is not duplicate. – Yukun Apr 07 '15 at 17:26
  • My bad. I am fairly certain R will in fact create an 8in by 20in for you but your issue may be how to get the printer driver to split this over several sheets of A4 (or letter) paper. – Dirk Eddelbuettel Apr 07 '15 at 17:32

2 Answers2

2

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:

  1. Generate the PDF plot so that it is divided into two different pages from the beginning?
  2. Take the PDF as is and during the print job setup find these settings which would print it onto two different pages by posterizing the original page?
  3. Post-process the PDF that you created to posterize it and create a 2-page output PDF (which you can then print)?

Assuming '1.': generate PDF plot distributed over 2 pages

Sorry, I cannot help here...

Assuming '2.': print setup to print 1 PDF page on 2 sheets of paper

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).

Assuming '3.': post-process 1 PDF page to stretch over 2 A4 pages

  1. 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.

  2. 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.

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
0

Maybe not the answer you are looking for but you could print it in another vectorial format (e.g. svg) and then export it as pdf on two pages with a (vectorial) image editor.

Edit: If ploting in pdf works well despite the big size of the graph there are also tools to split pdf pages. You can find some directions here: https://superuser.com/questions/437148/how-to-split-a-pdf-onto-multiple-pages-on-command-line

Windows equivalent of pdfposter could be Rasterbator or PosteRazor, for example.

Community
  • 1
  • 1
Prolix
  • 284
  • 2
  • 13