Graphics output to a two-page PDF file

I am making a forest plot and want to save it in a PDF file.

My forest area is large (8in * 20in). It can fit into a single page PDF file as follows:

dev.print(pdf, file="C:\\Work\\plot.pdf", width=8, height=20); 

But this is too long: when I print this PDF document on A4 paper, I need to compress it to fit the paper.

So, I want to save it in a two-page PDF file (from R). Ps: this is not a question of how to install the printer.

How to do it?

+6
source share
2 answers

So you can generate a PDF of size 8in x 20in == 203.2mm x 508mm == 576pt x 1440pt showing the graph.

Itโ€™s not clear to me from your question what exactly you want:

  • Create a PDF chart so that it is divided into two different pages from the very beginning?
  • Take PDF as it is, and while setting up your print job, find these settings that will print on two different pages by inserting the original page?
  • After processing the PDF file that you created for publishing and creating a two-page PDF output file (which you can print)?

Assuming '1.': create a 2-page PDF graphic

Sorry, I canโ€™t help here ...

Assuming '2.': set up printing to print 1 PDF page on 2 sheets of paper

If you are printing a PDF from Adobe Acrobat or from Adobe Reader, you will find the option in the Print Poster dialog box. Here you can choose to print a single PDF page on multiple sheets. (It also allows you to choose whether you want to partially overlap on a piece, and if you want to add clipping marks and the like to printouts).

Assuming "3.": after-process 1 page PDF to stretch over 2 A4 pages

  • MuPDF is a lightweight PDF format (and other document formats) created by the same company that also supports Ghostscript. MuPDF comes with an additional command line utility, mutool .

    Its poster subcommand can split PDF pages into smaller fragments and "expose" them. Thus, this command will do what you want:

     mutool poster -x 1 -y 2 input.pdf output.pdf 

    output.pdf will be divided into 1 part (i.e. not divided) in x- and two equal parts in y-direction. (You can divide it into any other number of segments if you want). Thus, output.pdf will have two pages, each 8in x 10in . A4 paper 8.26in x 11.69in measured in inches.

    When printing this data, you still need to enable the Print to fit Page Size check box in the print dialog box if you want to make the best use of A4 page size.

  • Ghostscript is a command line tool that can (among many other functions) be used to process PDF files (PDF file, modified PDF file). This can be (ab) used to cut PDF pages one and a half times.

    Here are a few previous StackOverflow answers that describe how to do this. You will need to adapt some parameters to your specific sizes, but the principles should be clear from these examples (although some of these split pages are left and right, not top and bottom, as you might need):

    The described method is more tedious, but not as direct as using the mutool poster method.

+1
source

It may not be the answer you are looking for, but you can print it in another vector format (e.g. svg) and then export it as pdf to two pages using the (vector) image editor.

Edit: if the graphics in pdf works well, despite the large size of the graphics, there are also tools for splitting PDF pages. Here you can find several directions: https://superuser.com/questions/437148/how-to-split-a-pdf-onto-multiple-pages-on-command-line

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

0
source

Source: https://habr.com/ru/post/984800/


All Articles