noDRM / DeDRM_tools

DeDRM tools for ebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PDF decryption fails

jrschumann opened this issue · comments

Question / bug report

Decryption fails with
"error writing pdf: 'utf-8' codec can't decode byte 0xa7 in position 5: invalid start byte"

Which version of Calibre are you running?

7.9

Which version of the DeDRM plugin are you running?

v10.0.9

If applicable, which version of the Kindle software are you running?

No response

Log output

ApplicationPaletteChange event ignored
Using calibre Qt style: True
2024-04-21 15:13:49.690 calibre-debug[93355:5076139] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
2024-04-21 15:13:50.570 calibre-debug[93355:5076139] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
2024-04-21 15:13:50.570 calibre-debug[93355:5076139] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
2024-04-21 15:13:50.570 calibre-debug[93355:5076139] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
2024-04-21 15:13:50.570 calibre-debug[93355:5076139] TSMSendMessageToUIServer: CFMessagePortSendRequest FAILED(-1) to send to port com.apple.tsm.uiserver
calibre Debug log
calibre 7.9  embedded-python: True
macOS-14.4.1-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '23.4.0', 'Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:08 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8122')
Python 3.11.5
OSX: ('14.4.1', ('', '', ''), 'arm64')
Interface language: None
EXE path: /Applications/calibre.app/Contents/MacOS/calibre-debug
Successfully initialized third party plugins: DeDRM (10, 0, 9)
calibre 7.9  embedded-python: True
macOS-14.4.1-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '23.4.0', 'Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:08 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8122')
Python 3.11.5
OSX: ('14.4.1', ('', '', ''), 'arm64')
Interface language: None
EXE path: /Applications/calibre.app/Contents/MacOS/calibre-debug
Successfully initialized third party plugins: DeDRM (10, 0, 9)
QPA platform: cocoa
devicePixelRatio: 2.0
logicalDpi: 72.0 x 72.0
physicalDpi: 93.50000140422914 x 93.50000140422914
[0.00] Starting up...
[0.01] Showing splash screen...
[0.14] splash screen shown
[0.14] Initializing db...
[0.29] db initialized
[0.29] Constructing main UI...
[0.69] GUI main window shown
[0.75] main UI initialized...
[0.75] Hiding splash screen
DeDRM v10.0.9: Trying to decrypt Brand eins (042024).pdf
DeDRM v10.0.9: Brand eins (042024).pdf is a PDF ebook with encryption EBX_HANDLER
DeDRM v10.0.9: Brand eins (042024).pdf is a PDF ebook (EBX) for UUID feb7f22a-510c-4454-b120-cef1587fbf55
DeDRM v10.0.9: Trying encryption key default_key
error writing pdf: 'utf-8' codec can't decode byte 0xa7 in position 5: invalid start byte
Traceback (most recent call last):
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2328, in decryptBook
    serializer.dump(outf)
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2142, in dump
    obj = doc.getobj(objid)
          ^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1869, in getobj
    (_,obj) = self.parser.nextobject()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 691, in nextobject
    (pos, token) = self.nexttoken()
                   ^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 565, in nexttoken
    (self.parse1, self.charpos) = self.parse1(self.buf, self.charpos)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 404, in parse_literal
    self.add_token(LIT(self.token))
                   ^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 225, in intern
    lit = self.classe(name)
          ^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 184, in __init__
    self.name = name.decode('utf-8')
                ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 5: invalid start byte
DeDRM v10.0.9: Failed to decrypt with key default_key after 0.2 seconds
DeDRM v10.0.9: Looking for new default Adobe Digital Editions Keys after 0.2 seconds
DeDRM v10.0.9: Trying a new default key
error writing pdf: 'utf-8' codec can't decode byte 0xa7 in position 5: invalid start byte
Traceback (most recent call last):
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2328, in decryptBook
    serializer.dump(outf)
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 2142, in dump
    obj = doc.getobj(objid)
          ^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 1869, in getobj
    (_,obj) = self.parser.nextobject()
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 691, in nextobject
    (pos, token) = self.nexttoken()
                   ^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 565, in nexttoken
    (self.parse1, self.charpos) = self.parse1(self.buf, self.charpos)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 404, in parse_literal
    self.add_token(LIT(self.token))
                   ^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 225, in intern
    lit = self.classe(name)
          ^^^^^^^^^^^^^^^^^
  File "/Users/jrschumann/Library/Preferences/calibre/plugins/DeDRM.zip/ineptpdf.py", line 184, in __init__
    self.name = name.decode('utf-8')
                ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 5: invalid start byte
DeDRM v10.0.9: Failed to decrypt with new default key after 0.4 seconds
DeDRM v10.0.9: Finished after 0.4 seconds
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 481, in get_file_type_metadata
  File "calibre/customize/builtins.py", line 325, in get_metadata
  File "calibre/ebooks/metadata/pdf.py", line 126, in get_metadata
ValueError: Could not read info dict from PDF
Syntax Error: Couldn't find the 'EBX_HANDLER' security handler
pdfinfo errored out with return code: 1
[3.65] splash screen hidden
[3.65] Started up in 3.65 seconds with 10610 books
Added Brand eins (042024) to db in: 0.0
Added 1 books in 0.7 seconds

Is it just this pdf that is having issues? Are you able to decrypt other Adobe DRM epubs or pdfs?

I had another file which seems only partially decrypted, but the log shows no error. Other files work fine. So hopefully its just this one file.

Is the file that seems partially decrypted a pdf too? If so, try a different pdf viewer. If other Adobe DRM books work, then it probably is something specific to this file. It may be something that @noDRM could take a look at.