當前位置: 首頁>>代碼示例>>Python>>正文


Python psparser.PSLiteral方法代碼示例

本文整理匯總了Python中pdfminer.psparser.PSLiteral方法的典型用法代碼示例。如果您正苦於以下問題:Python psparser.PSLiteral方法的具體用法?Python psparser.PSLiteral怎麽用?Python psparser.PSLiteral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pdfminer.psparser的用法示例。


在下文中一共展示了psparser.PSLiteral方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: decode_psl_list

# 需要導入模塊: from pdfminer import psparser [as 別名]
# 或者: from pdfminer.psparser import PSLiteral [as 別名]
def decode_psl_list(_list):
    return [ decode_text(value.name) if isinstance(value, PSLiteral) else value
        for value in _list ]

# via pdfminer.pdftypes, altered slightly 
開發者ID:jsvine,項目名稱:pdfplumber,代碼行數:7,代碼來源:utils.py

示例2: __init__

# 需要導入模塊: from pdfminer import psparser [as 別名]
# 或者: from pdfminer.psparser import PSLiteral [as 別名]
def __init__(self,
        stream,
        pages = None,
        laparams = None,
        precision = 0.001,
        password = ""
    ):
        self.laparams = None if laparams == None else LAParams(**laparams)
        self.stream = stream
        self.pages_to_parse = pages
        self.precision = precision
        rsrcmgr = PDFResourceManager()
        self.doc = PDFDocument(PDFParser(stream), password = password)
        self.metadata = {}
        for info in self.doc.info:
            self.metadata.update(info)
        for k, v in self.metadata.items():
            if hasattr(v, "resolve"):
                v = v.resolve()
            if type(v) == list:
                self.metadata[k] = list(map(decode_text, v))
            elif isinstance(v, PSLiteral):
                self.metadata[k] = decode_text(v.name)
            elif isinstance(v, bool):
                self.metadata[k] = v
            else:
                self.metadata[k] = decode_text(v)
        self.device = PDFPageAggregator(rsrcmgr, laparams=self.laparams)
        self.interpreter = PDFPageInterpreter(rsrcmgr, self.device) 
開發者ID:jsvine,項目名稱:pdfplumber,代碼行數:31,代碼來源:pdf.py

示例3: main

# 需要導入模塊: from pdfminer import psparser [as 別名]
# 或者: from pdfminer.psparser import PSLiteral [as 別名]
def main():
    fn = input("PDF filename: ")
    character = {}
    with open(fn, mode='rb') as f:
        parser = PDFParser(f)
        doc = PDFDocument(parser)
        try:
            fields = resolve1(doc.catalog['AcroForm'])
            fields = resolve1(fields['Fields'])
        except:
            raise Exception('This is not a form-fillable character sheet!')
        for i in fields:
            field = resolve1(i)
            name, value = field.get('T'), field.get('V')
            if isinstance(value, PSLiteral):
                value = value.name
            elif value is not None:
                try:
                    value = value.decode('iso-8859-1').strip()
                except:
                    pass

            character[name.decode('iso-8859-1').strip()] = value

        print(character)
    with open('./output/pdfsheet-test.json', mode='w') as f:
        json.dump(character, f, skipkeys=True, sort_keys=True, indent=4) 
開發者ID:avrae,項目名稱:avrae,代碼行數:29,代碼來源:pdfsheet.py

示例4: make_pdf_metadata_str

# 需要導入模塊: from pdfminer import psparser [as 別名]
# 或者: from pdfminer.psparser import PSLiteral [as 別名]
def make_pdf_metadata_str(value) -> str:
    if isinstance(value, bytes):
        metadata_str = value.decode('utf-8')
    elif isinstance(value, str):
        metadata_str = value
    elif isinstance(value, (PSLiteral, PSKeyword)):
        metadata_str = make_pdf_metadata_str(value.name)
    else:
        metadata_str = ''

    return metadata_str 
開發者ID:leovan,項目名稱:SciHubEVA,代碼行數:13,代碼來源:utils.py

示例5: resolve_dest

# 需要導入模塊: from pdfminer import psparser [as 別名]
# 或者: from pdfminer.psparser import PSLiteral [as 別名]
def resolve_dest(cls, dest):
        if isinstance(dest, str):
            dest = resolve1(doc.get_dest(dest))
        elif isinstance(dest, psparser.PSLiteral):
            dest = resolve1(doc.get_dest(dest.name))
        if isinstance(dest, dict):
            dest = dest['D']
        return dest 
開發者ID:bx,項目名稱:bootloader_instrumentation_suite,代碼行數:10,代碼來源:parse_am37x_register_tables.py


注:本文中的pdfminer.psparser.PSLiteral方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。