Two-a4-on-one-a3.sh: Difference between revisions

From creative crowd wiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
<pre>
<pre>
pdftk ongoing-circulations.pdf cat 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 output ongoing-circulations-double-pages.pdf
pdftk ongoing-circulations.pdf cat 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 output ongoing-circulations-double-pages.pdf
pdfjam --nup 2x1 --paper a3paper --landscape partylines-publication-double-pages.pdf
pdfjam --nup 2x1 --paper a3paper --landscape ongoing-circulations-double-pages.pdf
</pre>
</pre>


Line 35: Line 35:
The letters were RISO printed by Printroom, which is a space in Rotterdam dedicated to artist publications, small press and self-publishing. They also run a RISO workshop, where they have two A3 RISO machines plus four A4 ones, lots of different colors, and a range of machines for the post production, such as folding machines. Printroom asked us to prepare the print files on A3, because these RISO machines are the most reliable ones they have. At first i wasn't really sure how to do it... How can each A4 page of the PDF be duplicated and placed side-by-side on one A3 page without loosing any quality? Using raster editor software, like Gimp, would not make sense, as i was not sure if this would keep the quality of the PDF intact. Using vector editor software, like Inkscape, would also not make a lot of sense, because the fonts would not be rendered correctly. So i started to look for a tool that could be used from the command line.
The letters were RISO printed by Printroom, which is a space in Rotterdam dedicated to artist publications, small press and self-publishing. They also run a RISO workshop, where they have two A3 RISO machines plus four A4 ones, lots of different colors, and a range of machines for the post production, such as folding machines. Printroom asked us to prepare the print files on A3, because these RISO machines are the most reliable ones they have. At first i wasn't really sure how to do it... How can each A4 page of the PDF be duplicated and placed side-by-side on one A3 page without loosing any quality? Using raster editor software, like Gimp, would not make sense, as i was not sure if this would keep the quality of the PDF intact. Using vector editor software, like Inkscape, would also not make a lot of sense, because the fonts would not be rendered correctly. So i started to look for a tool that could be used from the command line.


The script does two things: it multiplies each page of a PDF by two, and it places two A4 pages on an A3 side-by-side. It took me a while to figure out how you could do this, but eventually [https://superuser.com/a/1549057 this answer on superuser.com] revealed a nice trick using <code>pdftk</code>. I have used <code>pdftk</code> in the past to work with PDFs to extract certain pages, so i was aware of the <code>cat</code> option and that you can use it to point to specific pages of your document. I had never seen <code>cat</code> being used though, to duplicate pages! It was a great discovery, specially because other ways of reaching the same outcome involved for loops written in bash, which would mean probably mean that i would write a small bash script to write this all out, and now i needed just one line of code.
The script does two things: it multiplies each page of a PDF by two, and it places two A4 pages on an A3 side-by-side. It took me a while to figure out how you could do this, but eventually [https://superuser.com/a/1549057 this answer on superuser.com] revealed a nice trick using <code>pdftk</code>. I have used <code>pdftk</code> in the past to work with PDFs to extract certain pages, so i was aware of the <code>cat</code> option and that you can use it to select specific pages of your document. I had never seen <code>cat</code> being used to duplicate pages though! It was a helpful discovery, specially because other suggestions i found to duplicate pages involved loops written in bash and the making of temporary files, which would probably mean that i would write a small bash script to do it, which is not a bad thing in itself, but now i needed just one command to do it. And i like actually how visible the gesture of duplicating becomes by repeating the page numbers in the command.  


So in the end, the script uses two PDF manipulation tools: <code>pdftk</code> and <code>pdfjam</code>.  
So in the end, the script uses two PDF manipulation tools: <code>pdftk</code> and <code>pdfjam</code>.  


The first line of the script calls <code>pdftk</code>, then uses <code>ongoing-circulations.pdf</code> as its input file, then uses <code>cat 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10</code> to select a range of pages of the input file, and writes it the <code>output</code> to <code>ongoing-circulations-double-pages.pdf</code>.
'''pdftk'''<br>
The first line of the script calls <code>pdftk</code>, provides <code>ongoing-circulations.pdf</code> as its input file, then uses <code>cat 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10</code> to select a range of pages of the input file, and finally writes it the <code>output</code> to <code>ongoing-circulations-double-pages.pdf</code>.


[[Category:Documentation]]
'''pdfjam'''<br>
The second line of the script call <code>pdfjam</code> and specifically the <code>--nup</code> module, which is used to shuffle pages around. By specifying <code>2x1</code> i asked the tool to place 2 pages horizontally and 1 vertically. The <code>--paper a3paper</code> selects the size of the pages and <code>--landscape</code> makes sure that the pages are in landscape orientation. The final step is to provide an input file, such as <code>ongoing-circulations-double-pages.pdf</code>. It then creates a file with the same filename + <code>-pdfjam</code>.
 
[[Category:Boilerplates]]

Latest revision as of 09:07, 7 April 2023

Script

pdftk duplicates each page
pdfjam places two A4 on one A3
pdftk ongoing-circulations.pdf cat 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 output ongoing-circulations-double-pages.pdf
pdfjam --nup 2x1 --paper a3paper --landscape ongoing-circulations-double-pages.pdf

How to work with it?

What does this script do?
It multiplies each page of a PDF by two + place two A4 pages on one A3 side-by-side.

In which context was it made?
The script is written to generate the print files for a publication called ongoing circulations, made and published by Varia in April 2023.

What software does it use?
pdftk + pdfjam

How to download these pieces of software?
Good question....

On which systems can this script run?
This works on Linux systems, also on Mac OS probably, but surely unfortunately not on Windows, because those systems work with another shell different from bash, which means that the Windows shell speaks a whole different language.

How to run the script?
Save the code above as a bash script with the .sh extention, for example: two-a4-on-one-a3.sh. You can use any kind of code editor for this. Once you did that, you can open your terminal, navigate to the folder where you saved the script, and run the script with: sh two-a4-one-a3.sh. Make sure you have the two PDF transformation tools installed (pdftk and pdfjam)!

Preparing print files for ongoing circulations

This script was written to generate the print files for the publication ongoing circulations to document a series of five collective learning sessions organised by Varia in 2022. Each session departed from a technological practice and made space for exploring, questioning and (re)turning (to) digital library software, plain text publishing protocols, web-to-print tools, high frequency radio communication, and colonial infrastructures. The publication is based on the format of the letter, a mode of address that was chosen to reach out to the participants of the sessions specifically, but could meanwhile also speak to a larger body of readers and invite them into the questions that were formulated and materials that were produced.

The letters were RISO printed by Printroom, which is a space in Rotterdam dedicated to artist publications, small press and self-publishing. They also run a RISO workshop, where they have two A3 RISO machines plus four A4 ones, lots of different colors, and a range of machines for the post production, such as folding machines. Printroom asked us to prepare the print files on A3, because these RISO machines are the most reliable ones they have. At first i wasn't really sure how to do it... How can each A4 page of the PDF be duplicated and placed side-by-side on one A3 page without loosing any quality? Using raster editor software, like Gimp, would not make sense, as i was not sure if this would keep the quality of the PDF intact. Using vector editor software, like Inkscape, would also not make a lot of sense, because the fonts would not be rendered correctly. So i started to look for a tool that could be used from the command line.

The script does two things: it multiplies each page of a PDF by two, and it places two A4 pages on an A3 side-by-side. It took me a while to figure out how you could do this, but eventually this answer on superuser.com revealed a nice trick using pdftk. I have used pdftk in the past to work with PDFs to extract certain pages, so i was aware of the cat option and that you can use it to select specific pages of your document. I had never seen cat being used to duplicate pages though! It was a helpful discovery, specially because other suggestions i found to duplicate pages involved loops written in bash and the making of temporary files, which would probably mean that i would write a small bash script to do it, which is not a bad thing in itself, but now i needed just one command to do it. And i like actually how visible the gesture of duplicating becomes by repeating the page numbers in the command.

So in the end, the script uses two PDF manipulation tools: pdftk and pdfjam.

pdftk
The first line of the script calls pdftk, provides ongoing-circulations.pdf as its input file, then uses cat 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 to select a range of pages of the input file, and finally writes it the output to ongoing-circulations-double-pages.pdf.

pdfjam
The second line of the script call pdfjam and specifically the --nup module, which is used to shuffle pages around. By specifying 2x1 i asked the tool to place 2 pages horizontally and 1 vertically. The --paper a3paper selects the size of the pages and --landscape makes sure that the pages are in landscape orientation. The final step is to provide an input file, such as ongoing-circulations-double-pages.pdf. It then creates a file with the same filename + -pdfjam.