当前位置: 首页>>代码示例>>Python>>正文


Python LAParams.direction方法代码示例

本文整理汇总了Python中pdfminer.layout.LAParams.direction方法的典型用法代码示例。如果您正苦于以下问题:Python LAParams.direction方法的具体用法?Python LAParams.direction怎么用?Python LAParams.direction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pdfminer.layout.LAParams的用法示例。


在下文中一共展示了LAParams.direction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pdfminer.layout import LAParams [as 别名]
# 或者: from pdfminer.layout.LAParams import direction [as 别名]
def main(argv):
  import getopt
  def usage():
    print ('usage: %s [-d] [-p pagenos] [-P password] [-c codec] '
           '[-D direction] [-M char_margin] [-L line_margin] [-W word_margin] '
           '[-t text|html|sgml|tag] [-o output] file ...' % argv[0])
    return 100
  try:
    (opts, args) = getopt.getopt(argv[1:], 'dp:P:c:D:M:L:W:t:o:C:D:m:')
  except getopt.GetoptError:
    return usage()
  if not args: return usage()
  # debug option
  debug = 0
  # path option
  cmapdir = find_cmap_path()
  # input option
  password = ''
  pagenos = set()
  maxpages = 0
  # output option
  outfile = None
  outtype = None
  codec = 'utf-8'
  pageno = 1
  scale = 1
  showpageno = True
  laparams = LAParams()
  for (k, v) in opts:
    if k == '-d': debug += 1
    elif k == '-C': cmapdir = v
    elif k == '-P': password = v
    elif k == '-p': pagenos.update( int(x)-1 for x in v.split(',') )
    elif k == '-m': maxpages = int(v)
    elif k == '-t': outtype = v
    elif k == '-c': codec = v
    elif k == '-o': outfile = v
    elif k == '-s': scale = float(v)
    elif k == '-D': laparams.direction = v
    elif k == '-M': laparams.char_margin = float(v)
    elif k == '-L': laparams.line_margin = float(v)
    elif k == '-W': laparams.word_margin = float(v)
  #
  CMapDB.debug = debug
  PDFResourceManager.debug = debug
  PDFDocument.debug = debug
  PDFParser.debug = debug
  PDFPageInterpreter.debug = debug
  PDFDevice.debug = debug
  #
  CMapDB.initialize(cmapdir)
  rsrc = PDFResourceManager()
  if not outtype:
    outtype = 'text'
    if outfile:
      if outfile.endswith('.htm') or outfile.endswith('.html'):
        outtype = 'html'
      elif outfile.endswith('.sgml'):
        outtype = 'sgml'
      elif outfile.endswith('.tag'):
        outtype = 'tag'
  if outfile:
    outfp = file(outfile, 'w')
  else:
    outfp = sys.stdout
  if outtype == 'text':
    device = TextConverter(rsrc, outfp, codec=codec, laparams=laparams)
  elif outtype == 'sgml':
    device = SGMLConverter(rsrc, outfp, codec=codec, laparams=laparams)
  elif outtype == 'html':
    device = HTMLConverter(rsrc, outfp, codec=codec, scale=scale, laparams=laparams)
  elif outtype == 'tag':
    device = TagExtractor(rsrc, outfp, codec=codec)
  else:
    return usage()
  for fname in args:
    fp = file(fname, 'rb')
    process_pdf(rsrc, device, fp, pagenos, maxpages=maxpages, password=password)
    fp.close()
  device.close()
  return
开发者ID:frid,项目名称:PythonPool,代码行数:83,代码来源:pdf2txt.py


注:本文中的pdfminer.layout.LAParams.direction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。