Averell7 / PdfBooklet

Creates booklets from Pdf files, and much more
45 stars 13 forks source link

GTK errors, can't open password protected files #6

Closed UserXYZ closed 6 years ago

UserXYZ commented 6 years ago

warnings when starting pdfbooklet:

(pdfbooklet:30706): Gtk-WARNING **: Theme parsing error: gtk.css:68:35: The style property GtkButton:child-displacement-x is deprecated and shouldn't be used anymore. It will be removed in a future version
(pdfbooklet:30706): Gtk-WARNING **: Theme parsing error: gtk.css:69:35: The style property GtkButton:child-displacement-y is deprecated and shouldn't be used anymore. It will be removed in a future version
(pdfbooklet:30706): Gtk-WARNING **: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
PdfReadWarning: Xref table not zero-indexed. ID numbers for objects will not be corrected. [pdf.py:1722]

and an error when opening password protected file:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pdfbooklet/pdfbooklet.py", line 1275, in openMru
    ini.loadPdfFiles()
  File "/usr/lib/python3.6/site-packages/pdfbooklet/pdfbooklet.py", line 781, in loadPdfFiles
    password = self.get_text(None, _("Please, enter the password for this file"))
AttributeError: 'TxtOnly' object has no attribute 'get_text'

This error is a big one, it should be corrected firstly...

Averell7 commented 6 years ago

thanks for the information. Unfortunately, the fix will be partial, because PYPdf2 supports only algorithms 1 and 2. AES encrytped files will not be opened and I can do nothing about it.

UserXYZ commented 6 years ago

Hmmm, I don't think that's the problem here...from the error it seams if a popup window that would request a password to be entered is not created (I am sure it does not show) because of this attribute error... Can you test that, regardless of the encrypting method used in the pdf file itself? You could use some regular pdf, create a password protected copy of it, with the supported cypher, and see if pdfbooklet shows "enter the password" popup...if it does, then it's a matter of implementing a check of the used encryption version and give the appropriate error popup if used version of encryption is not supported.

Averell7 commented 6 years ago

I didn't say it was the problem you encountered, it comes from a bug due to the migration of some functions in the TextOnly class. There was really a bug, and I fixed it already (not yet uploaded on Github because the present version is unstable). But I verified that this allows opening old encrypting methods, the new ones raise the following error :

File "D:\Mes Documents\en cours\PdfBooklet3\PyPDF2_G\pdf.py", line 1982, in _decrypt
    raise NotImplementedError("only algorithm code 1 and 2 are supported")
NotImplementedError: only algorithm code 1 and 2 are supported
Averell7 commented 6 years ago

I fixed it in master (with the above indicated limitations).