Difference between revisions of "Command line tools to edit pdfs"

From mn/geo/geoit
Jump to: navigation, search
Line 1: Line 1:
Programs such as [http://www.google.no/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CC0QFjAB&url=http%3A%2F%2Fwww.imagemagick.org%2Fscript%2Fconvert.php&ei=M0XsVPeANIj2PNKZgOgM&usg=AFQjCNErUbpIH8-eDSPmoJflwqnPd5Rjhg&sig2=MOIgi-jXGIboSIsyZ9gQ7g&bvm=bv.86475890,d.ZWU Imagemagick] (the "convert" command), [http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam/ PDFjam] and [http://www.linux.com/news/software/applications/8229-putting-together-pdf-files Ghostscript] provide options to edit PDFs, such as merging, splitting, rotating PDFs, or converting other file formats to PDF.
+
<parsererror>XML Parsing Error: mismatched tag. Expected: &lt;/link&gt;. Location: https://wiki.uio.no/mn/geo/geoit/index.php?title=Command_line_tools_to_edit_pdfs&action=edit Line Number 8, Column 714:<sourcetext>&lt;/pre&gt;&lt;p&gt;will result in files named 'myfile1-turned.pdf' and 'myfile2-turned.pdf'. &lt;i&gt;(From &lt;a href="http://linux.die.net/man/1/pdf90"&gt;http://linux.die.net/man/1/pdf90&lt;/a&gt;)&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;img class="FCK__MWCategory" src="https://wiki.uio.no/mn/geo/geoit/extensions/WYSIWYG/ckeditor/images/spacer.gif?t=B49E5BQ" data-cke-realelement="%3Cspan%20class%3D%22fck_mw_category%22%20sort%3D%22Command_line%22%3ECommand%20line%3C%2Fspan%3E" data-cke-real-node-type="1" alt="Unknown Object" title="Unknown Object" data-cke-real-element-type="span" align=""/&gt;&lt;/p&gt;&lt;div is_mini="true" style="left: 971px; top: 293px;" id="s3gt_translate_tooltip"&gt;&lt;link href="chrome://s3gt/skin/s3gt_tooltip.css" type="text/css" rel="stylesheet"&gt;&lt;/div&gt;&lt;/body&gt; -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^</sourcetext></parsererror>
 
 
= Join PDFs into one file =
 
 
 
Install Imagemagick (or log on to Sverdrup), and use the "convert" command:
 
 
 
convert infile1.pdf infile2.pdf outfile.pdf
 
 
 
If the quality is reduced, use the -density flag (the higher number afterwards, the better. 600 is good). If you are converting from a JPEG/MIFF/PNG file to pdf, use -quality instead.
 
 
 
convert -density 600 infile1.pdf infile2.pdf outfile.pdf
 
 
 
 
== Join picture files into one file ==
 
 
 
convert -quality 600 infile1.jpg infile2.jpg outfile.pdf
 
 
 
== Alternative way to do this in Windows ==
 
 
 
In Windows, files can be merged using Adobe Acrobat Pro (on a remote desktop to win.uio.no), choose "Merge PDFs into one file".
 
 
 
 
 
 
 
= Extract pages from PDF =
 
 
 
Install PDFjam to extract pages from a PDF into another PDF.
 
 
 
pdfjam -o outfile.pdf infile.pdf wantedpage1,wantedpage2
 
 
 
[http://tex.stackexchange.com/questions/79623/quickly-extracting-individual-pages-from-a-document See also stackexchange.]
 
 
 
== Join PDFs into one file - several sheets per page ==
 
 
 
After convert has joined several PDFs, PDFjam can be used to put several sheets on one page. Here, I prepare a 12-page PDFs into one-page PDF (3 columns, 4 rows), before printing:
 
 
 
pdfjam --nup 3x4 --landscape my_12_slides.pdf --outfile my_1_page_handout.pdf
 
 
 
== Rotate pages ==
 
 
 
Contained in PDFjam is a lot of useful commands, such as [http://linux.die.net/man/1/pdf90 pdf90] which rotates your file:
 
 
 
''pdf90 operates on one or more PDF files, and (either with the '--batch' option or with '--outfile DIR' where 'DIR' is a directory) the resulting files have the suffix 'rotated90' applied to their names by default. To change the suffix, use the '--suffix' option, for example''
 
 
 
pdf90 --suffix '-turned' --batch myfile1.pdf myfile2.pdf
 
 
 
will result in files named 'myfile1-turned.pdf' and 'myfile2-turned.pdf'. ''(From [http://linux.die.net/man/1/pdf90 http://linux.die.net/man/1/pdf90])''
 
 
 
[[Category:Command line|Command_line]]
 

Revision as of 13:23, 24 February 2015

<parsererror>XML Parsing Error: mismatched tag. Expected: </link>. Location: https://wiki.uio.no/mn/geo/geoit/index.php?title=Command_line_tools_to_edit_pdfs&action=edit Line Number 8, Column 714:<sourcetext></pre><p>will result in files named 'myfile1-turned.pdf' and 'myfile2-turned.pdf'. <i>(From <a href="http://linux.die.net/man/1/pdf90">http://linux.die.net/man/1/pdf90</a>)</i></p><p><img class="FCK__MWCategory" src="https://wiki.uio.no/mn/geo/geoit/extensions/WYSIWYG/ckeditor/images/spacer.gif?t=B49E5BQ" data-cke-realelement="%3Cspan%20class%3D%22fck_mw_category%22%20sort%3D%22Command_line%22%3ECommand%20line%3C%2Fspan%3E" data-cke-real-node-type="1" alt="Unknown Object" title="Unknown Object" data-cke-real-element-type="span" align=""/></p><div is_mini="true" style="left: 971px; top: 293px;" id="s3gt_translate_tooltip"><link href="chrome://s3gt/skin/s3gt_tooltip.css" type="text/css" rel="stylesheet"></div></body> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^</sourcetext></parsererror>