python怎么生成pdf,python操作pdf文件
PyPDF2编码问题py pdf2 .utils。pdfreaderrillegalacharacternameobject
使用PyPDF2合并便携文档格式文件时,将报告以下错误:
跟踪后台(mostrecentcalllast):文件丁: (项目(我的项目(venv(lib(site-packages)py pdf 2)agent in ragent)-8 ) unicode decode错误:" utf-8 "编解码器无法tdecodebyte 0 xcbinposition 83360 invalidcontinuationbyteduringhandlingofabovevevevevevevition 0跟踪后台(mostrecentcalllast):文件丁: (项目(我的项目(应用程序)后台stage busi _ contract _ manage _ view)in post merge _ PDF _ result=merge _ PDF(final _ files,PDF _ pa manage doc _ convert _ util。py ,第86行,在合并_ PDF PDF _ writer。写入(新文件)文件d:)projects _ myprite第482行,在自我书写中sweepindirection self ._root)文件: (项目)我的项目)我的pdf.py ,第571行,in _ sweepindirectreferencessself ._ sweeppind site-packages \ py pdf 2 \ pdf。py ,第547行,in _ sweepindirectreferencesvalue=self ._ sweepindirectreferences (eelf ._ sweepindirectreferences))(elf)65我更喜欢571行,in _ sweepindirectreferencesself ._ sweepinnces真实数据(文件(丁:(项目(我的项目)venv(lib(sitive))in _ sweepindirectreferencesvalue=self ._ sweepindirectreferences(外部映射,值)文件丁: (项目)我的项目in _ sweepindirectreferencesvalue=self ._ sweepindirectreferences(扩展映射,数据[我])文件site-packages \ py pdf in _ sweepindirectreferencesself ._ sweepindirectreferences(扩展映射我的项目\ venv \ lib \ site-packages \ py pdf in _ sweepindirectreferencesvalue=self ._ _值(文件(丁: (项目(我的项目)venv ) lib(站点包)in _ sweepindirectreferencesvalue=self ._ sweepindirectreferences(外部映射,值)文件丁: (项目)我的项目in _ sweepindirectreferencesvalue=self ._ sweepindirectreferences(外部映射,值)文件d 3337 site-packages \ py in _ sweepindirectreferencesnewobj=data。pdf。getobject(数据)文件站点包\ py pdf F2 \ pdf。py ,第1611行,PyPDF2 \ generic.py ,第66行,in readbjectreturndictionaryobject。readfromstream(流,pdf)文件d 3360(project inreadfromstreamvalue=read object(stream,pdf)file d 3360)projects(my projects)my generic。py ,第60行,inreadodo pdf)文件d:)项目)我的项目)我的generic.py ,第492行,inreadfromstreamraiseutils.pdf读取错误(非法
文件" d:\ projects \ my project \ venv \ lib \ site-packages \ py pdf 2 \ generic。py”,行第484484行的原始代码:
try:返回名称对象(名称。decode(utf-8))except)unicode encode error,unicode decode error(ase:# nameobjectshouldrenpresenter regular lactors #带 # 后跟符号 shexnumberifnotpdf。严格:警告。warn(illegalternarnnameobject),utils。pdfreadwarning(return name object(name)else:引发utils.pdf读取错误(illegalternarnameobject’)是exll
returnnameobject(name.decode))修改后
try:returnname对象(名称。decode(utf-8))except)unicode encode error、unicode decode error(ase:try:return name对象)名称。decode)“gbk”)除外)unicodeeencodeerror、unicode decode error(ase:# nameobjectshouldrepresenterrorregular characters #带 # 后跟bythesymbol shexnumberifnotpdf。strict:warning(illegalternannnameobject)、utils。pdf读取警告(returnname object(name)else:引发utils.pdf读取错误(非法
lib/site-packages/py pdf 2/utils巴拉圭第238行
如果len(s)2:BC[s]=r return r修正后代码:
try:r=s . encode(Latin-1))异常exception ase:r=s . encode(utf-8))if len(s)2:BC)=rRRR
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。