Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added: -R option.

  • Loading branch information...
commit bb6f9b6fc94c962e55bbb44a0aa6f33a42dbf6af 1 parent af8c4a6
@euske authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 tools/pdf2txt.py
View
13 tools/pdf2txt.py
@@ -14,12 +14,14 @@
def main(argv):
import getopt
def usage():
- print ('usage: %s [-d] [-p pagenos] [-m maxpages] [-P password] [-o output] [-C] '
- '[-n] [-A] [-V] [-M char_margin] [-L line_margin] [-W word_margin] [-F boxes_flow] '
- '[-Y layout_mode] [-O output_dir] [-t text|html|xml|tag] [-c codec] [-s scale] file ...' % argv[0])
+ print ('usage: %s [-d] [-p pagenos] [-m maxpages] [-P password] [-o output]'
+ ' [-C] [-n] [-A] [-V] [-M char_margin] [-L line_margin] [-W word_margin]'
+ ' [-F boxes_flow] [-Y layout_mode] [-O output_dir] [-R rotation]'
+ ' [-t text|html|xml|tag] [-c codec] [-s scale]'
+ ' file ...' % argv[0])
return 100
try:
- (opts, args) = getopt.getopt(argv[1:], 'dp:m:P:o:CnAVM:L:W:F:Y:O:t:c:s:')
+ (opts, args) = getopt.getopt(argv[1:], 'dp:m:P:o:CnAVM:L:W:F:Y:O:R:t:c:s:')
except getopt.GetoptError:
return usage()
if not args: return usage()
@@ -33,6 +35,7 @@ def usage():
outfile = None
outtype = None
imagewriter = None
+ rotation = 0
layoutmode = 'normal'
codec = 'utf-8'
pageno = 1
@@ -56,6 +59,7 @@ def usage():
elif k == '-F': laparams.boxes_flow = float(v)
elif k == '-Y': layoutmode = v
elif k == '-O': imagewriter = ImageWriter(v)
+ elif k == '-R': rotation = int(v)
elif k == '-t': outtype = v
elif k == '-c': codec = v
elif k == '-s': scale = float(v)
@@ -101,6 +105,7 @@ def usage():
for page in PDFPage.get_pages(fp, pagenos,
maxpages=maxpages, password=password,
caching=caching, check_extractable=True):
+ page.rotate = (page.rotate+rotation) % 360
interpreter.process_page(page)
fp.close()
device.close()
Please sign in to comment.
Something went wrong with that request. Please try again.