Pdftk: Difference between revisions

No edit summary
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight"
Tags: Mobile edit Mobile web edit
Line 16: Line 16:


'''Discard the cover page of a pdf'''
'''Discard the cover page of a pdf'''
<source lang="bash">
<syntaxhighlight lang="bash">
pdftk wCover.pdf cat 2-end output NoCover.pdf
pdftk wCover.pdf cat 2-end output NoCover.pdf
</source>
</syntaxhighlight>


===Collating two-sided documents===
===Collating two-sided documents===
2-sided document?  No problem.  Scan the original face side up first (odd pages); then flip it over and scan the second (even pages).  Astute people will recognized that the second document is in reverse order compared to the first document.  pdfTK can not only Merge the two documents, but '''ALSO''' can reverse the second document during collation so that the pages are in order.
2-sided document?  No problem.  Scan the original face side up first (odd pages); then flip it over and scan the second (even pages).  Astute people will recognized that the second document is in reverse order compared to the first document.  pdfTK can not only Merge the two documents, but '''ALSO''' can reverse the second document during collation so that the pages are in order.
<source lang="bash">
<syntaxhighlight lang="bash">
pdftk A=my.even.pdf B=my.odd.pdf shuffle A Bend-1 output my.full.pdf
pdftk A=my.even.pdf B=my.odd.pdf shuffle A Bend-1 output my.full.pdf
</source>
</syntaxhighlight>
In our example, We specify documents handles using 'A' and 'B' to make it easier to refer to them. The operator "shuffle" acts like "cat" but means to collate the documents like shuffling a deck of cards.  Using the 'A' and 'B' handles, we can also specify a range, and by reversing the range that 'B' should be read from the "end" to "page 1" using the handle "Bend-1".
In our example, We specify documents handles using 'A' and 'B' to make it easier to refer to them. The operator "shuffle" acts like "cat" but means to collate the documents like shuffling a deck of cards.  Using the 'A' and 'B' handles, we can also specify a range, and by reversing the range that 'B' should be read from the "end" to "page 1" using the handle "Bend-1".


===Discard blank pages===
===Discard blank pages===
If you have a scan that added blank pages (every even page), and you want to get rid of those, you would ask pdftk to 'cat' pages 1-end (but only the odd ones) and 'output' that to the file of your choice.
If you have a scan that added blank pages (every even page), and you want to get rid of those, you would ask pdftk to 'cat' pages 1-end (but only the odd ones) and 'output' that to the file of your choice.
<source lang="bash">
<syntaxhighlight lang="bash">
pdftk ~/Desktop/DOC033115.pdf cat 1-endodd output ~/Desktop/ProofOfLearning.pdf
pdftk ~/Desktop/DOC033115.pdf cat 1-endodd output ~/Desktop/ProofOfLearning.pdf
</source>
</syntaxhighlight>


===Cleaning up Bank Statements===
===Cleaning up Bank Statements===
This is a long one, because Jack Henry sucks.
This is a long one, because Jack Henry sucks.
<source lang="bash">
<syntaxhighlight lang="bash">
# first download the statements, manually inserting a month digit for each one
# first download the statements, manually inserting a month digit for each one
# then rename the whole batch to something more intelligent
# then rename the whole batch to something more intelligent
Line 46: Line 46:
# and delete the monthly statement clutter
# and delete the monthly statement clutter
rm 2014_ifs_??.pdf
rm 2014_ifs_??.pdf
</source>
</syntaxhighlight>
You don't need to use extended globbing <ref>http://mywiki.wooledge.org/glob </ref>, but if you did, you'd be able to use patterns like
You don't need to use extended globbing <ref>http://mywiki.wooledge.org/glob </ref>, but if you did, you'd be able to use patterns like
<source lang="bash">
<syntaxhighlight lang="bash">
# turn on extended globbing
# turn on extended globbing
shopt -s extglob
shopt -s extglob
Line 55: Line 55:
# unset  
# unset  
shopt -u extglob
shopt -u extglob
</source>
</syntaxhighlight>


===Order Numerically===
===Order Numerically===
This is really a feature of the <code>ls</code> command.  If you have a series of files you wish to load in numeric order, but the numbering system is 'natural' instead of computer-friendly, then use the -v option to <code>ls</code>.  I.e. you have 1.pdf, 2.pdf... 11.pdf, 12.pdf.   
This is really a feature of the <code>ls</code> command.  If you have a series of files you wish to load in numeric order, but the numbering system is 'natural' instead of computer-friendly, then use the -v option to <code>ls</code>.  I.e. you have 1.pdf, 2.pdf... 11.pdf, 12.pdf.   
<source lang="bash">
<syntaxhighlight lang="bash">
pdftk $(ls -v *.pdf) cat output my.combined.pdf
pdftk $(ls -v *.pdf) cat output my.combined.pdf
</source>
</syntaxhighlight>


{{References}}
{{References}}


[[Category:Tools]]
[[Category:Tools]]