Wikipedia:Reference desk/Archives/Computing/2023 April 23

= April 23 =

Undo 2-up PDF
I have a PDF document that has been converted to a "2-up" format, i.e. each page of the PDF represents 2 pages of an original document, side by side. Working from the Linux command line, is there an easy way to undo that conversion and recreate the original document? --174.89.12.187 (talk) 09:25, 23 April 2023 (UTC)


 * The best I can think of is:
 * pop the pdf into individual one-page pdf files with PDFtk
 * use pdfcrop to extract the left (and again the right) sub pages - see https://askubuntu.com/questions/124692/command-line-tool-to-crop-pdf-files
 * merge the resulting pages back into one, again with PDFtk (with  )
 * you may want to rotate the pages 90 degrees (


 * -- Finlay McWalter··–·Talk 10:46, 23 April 2023 (UTC)
 * A similar method to that suggested by is to use   and   depending upon what your distro provides. Martin of Sheffield (talk) 11:36, 23 April 2023 (UTC)
 * Depending upon what is in the PDF, you might want to consider pdftext(1). There's also pdftohtml(1) and pdftops(1) which might possibly help.  It's also worth having a look at the formatting of the double pages, try file page-1.pdf or similar and see if there is an easy way to split them. Martin of Sheffield (talk) 13:54, 23 April 2023 (UTC)

Thanks, folks. I should be fine from there. --174.89.12.187 (talk) 18:19, 23 April 2023 (UTC)
 * The tricky part was figuring out how to use pdfcrop, and I may as well write it up here in case it helps someone else. I finally learned that I had to use the option -clip as well as -bbox, and specify the bounding box as a string of four space-separated numbers in units of points measured from the left and bottom.  The original pages were A5 size, which is 419.53 &times; 595.28 points, so I ended up using:

pdfcrop -clip -bbox '0 0 419.53 595.28' infile.pdf leftpage.pdf pdfcrop -clip -bbox '419.53 0 839.06 595.28' infile.pdf rightpage.pdf
 * --174.89.12.187 (talk) 16:35, 28 April 2023 (UTC)