Hello,
I have a pdf file with 2 nup sub-pages per landscape page and I need to convert this to an upright document whose pages are the sub-pages. I tried to use pstops but I could not make out how to do this. I can also use the other psutils, poppler, pdfjam, pdftk and Texlive, And of course I can use Gimp or something like it to make the separation by hand, but this will be too much work,
Any help will be very welcome!
LaTeX forum ⇒ Conversion Tools ⇒ How to convert from a 2nup pdf to a single page one
How to convert from a 2nup pdf to a single page one
It seems the problem I am dealing with has no known solution, so I offer a poor man's one:
- use pdftk, or any similar tool to create a pdf file for each page in the original document
- for each page in pg001.pdf .... convert from pdf to png or tiff or some other raster format accepted by ImageMagick, and then create a file with the subpages:
where 2x1@ means that there are 2 subpages in 2nup format and pc1_%d.png gives the pattern for the resulting filenames
- now convert each subpage file to pdf
It is clear that the conversion from pdf to a raster format implies a quality loss that cannot be avoided if there are no pdf nor ps tools for doing the job.
- use pdftk, or any similar tool to create a pdf file for each page in the original document
mkdir temp ; cd temp pdftk burst ../original.pdf
- for each page in pg001.pdf .... convert from pdf to png or tiff or some other raster format accepted by ImageMagick, and then create a file with the subpages:
convert-im6.q16 pg_0001.pdf pg1.png convert-im6.q16 pg1.png -crop 2x1@ +repage pc1_%d.png
where 2x1@ means that there are 2 subpages in 2nup format and pc1_%d.png gives the pattern for the resulting filenames
- now convert each subpage file to pdf
convert-im6.q16 pc1_0.png pc1_0.pdf
It is clear that the conversion from pdf to a raster format implies a quality loss that cannot be avoided if there are no pdf nor ps tools for doing the job.
How to convert from a 2nup pdf to a single page one
Here is an upgrade to my previous poor man's solution that will be of use if one only wants to process images in the original pdf, what will be the case if it contains a scanned document.
Instead of using pdftk to get the pages and then converting them to png, pdfimages should be used to get the images as they are in the pdf, keeping its resolution and format (png, jpeg, ...):
where -f and -l give the numbers of the first and last pages, -all keeps the original format, and pg the prefix for the resulting files,
Then follows the cropping of the subpages as before:
As in my case I am dealing with scanned documents no quality loss is to be expected and I will mark this as solved.
Instead of using pdftk to get the pages and then converting them to png, pdfimages should be used to get the images as they are in the pdf, keeping its resolution and format (png, jpeg, ...):
pdfimages -f 1 -l 4 -all ../original.pdf pg
where -f and -l give the numbers of the first and last pages, -all keeps the original format, and pg the prefix for the resulting files,
Then follows the cropping of the subpages as before:
convert-im6.q16 pg1.png -crop 2x1@ +repage pc1_%d.png convert-im6.q16 pc1_0.png pc1_0.pdf ...
As in my case I am dealing with scanned documents no quality loss is to be expected and I will mark this as solved.
Who is online
Users browsing this forum: No registered users and 1 guest