tjwei / translatePDF

Convert Simplized Chinese PDF to Traditional Chinese PDF
43 stars 10 forks source link

error after decoded pdf #1

Open zeteticl opened 6 years ago

zeteticl commented 6 years ago

python2 tpdfrw.py cccht2.pdf Font not translated: /TT1 /VMGCWN+MicrosoftYaHeiLight Font not translated: /TT0 /GBCYZR+SimSun handle ( ) handle ( ) handle ( ) handle ( ) Font translated: /C0_0 /UDSRIP+MFLangSong_Noncommercial-Regular font {'/Encoding': '/Identity-H', '/Type': '/Font', '/BaseFont': '/UDSRIP+MFLangSong_Noncommercial-Regular', '/Subtype': '/Type0', '/DescendantFonts': (53332, 0), '/ToUnicode': (53333, 0)} --> [(58825, 0)] --> None (<type 'exceptions.AttributeError'>, AttributeError("'NoneType' object has no attribute 'has_key'",), <traceback object at 0x3d128c0>) readStream: The object does not have a stream? None Traceback (most recent call last): File "tpdfrw.py", line 320, in main() File "tpdfrw.py", line 313, in main tpdf=TranslatedPdf(args.input, translator, args.default_ttf) File "tpdfrw.py", line 181, in init self._translatePage(page, translator) File "tpdfrw.py", line 267, in _translatePage self._updatePageFontDecodeDicts(page) File "tpdfrw.py", line 218, in _updatePageFontDecodeDicts self.decodeDicts[font_id]=getFontDecodeDict(font) File "tpdfrw.py", line 90, in getFontDecodeDict tmpttf=fontTools.ttLib.TTFont(StringIO.StringIO(ttfbuf)) File "/usr/lib64/python2.7/site-packages/fontTools/ttLib/init.py", line 182, in init self.reader = sfnt.SFNTReader(file, checkChecksums, fontNumber=fontNumber) File "/usr/lib64/python2.7/site-packages/fontTools/ttLib/sfnt.py", line 84, in init raise ttLib.TTLibError("Not a TrueType or OpenType font (not enough data)") fontTools.ttLib.TTLibError: Not a TrueType or OpenType font (not enough data)

zeteticl commented 3 years ago

python2 tpdfrw.py xxx.pdf Traceback (most recent call last): File "tpdfrw.py", line 320, in main() File "tpdfrw.py", line 311, in main with opencc.OpenCC(args.opencc_config) as cc: File "/home/zeteticl/translatePDF/PyOpenCC.py", line 24, in init self.libopencc.opencc_perror.argtypes = [c_char_p] File "/usr/lib64/python2.7/ctypes/init.py", line 373, in getattr func = self.getitem(name) File "/usr/lib64/python2.7/ctypes/init.py", line 378, in getitem func = self._FuncPtr((name_or_ordinal, self)) AttributeError: /lib/libopencc.so.2: undefined symbol: opencc_perror

jun-jing commented 3 years ago

(py27) D:\Code\pythonRequireProj\pdfContentSimToTra>python tpdfrw.py samples\Test.pdf

Traceback (most recent call last): File "tpdfrw.py", line 320, in main() File "tpdfrw.py", line 311, in main with opencc.OpenCC(args.opencc_config) as cc: File "D:\Code\pythonRequireProj\pdfContentSimToTra\PyOpenCC.py", line 17, in init self.libopencc = cdll.LoadLibrary(find_library('opencc')) File "D:\Program\anaconda3\envs\py27\lib\ctypes__init__.py", line 444, in LoadLibrary return self._dlltype(name) File "D:\Program\anaconda3\envs\py27\lib\ctypes__init.py", line 366, in init__ self._handle = _dlopen(self._name, mode) TypeError: expected string or Unicode object, NoneType found