Kaj Huisman - 2013-06-07

I can confirm this, also reported it to the ubuntu launchpad
The problem is in the PDF_Doc class's init method. I created a workaround fix for this, see this patch:
1028,1029c1028,1035
< self.document = poppler.document_new_from_file (file_prefix + self.copyname, None)
< self.npage = self.document.get_n_pages()
---
> try:
> self.document = poppler.document_new_from_file (file_prefix + self.copyname, None)
> self.npage = self.document.get_n_pages()
> except gobject.GError as e:
> print 'Failed to open document. Reason: %s' % (e)
> self.nfile = 0
> self.npage = 0
>

However, this causes an other bug to raise its head, which I haven't investigated enough yet. The code that now fails is in PdfShuffler class's add_pdf_pages method which does not check for a None existant PDF_Doc, perhaps it is a simple fix to test if the pdfdoc equals None, but I have not investigated it enough to make a definitive statement about it. Anyway, with the above patch, a malformed PDF might cause the following Exception to be raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pdfshuffler/pdfshuffler.py", line 593, in on_action_add_doc_activate
self.add_pdf_pages(filename)
File "/usr/lib/python2.7/dist-packages/pdfshuffler/pdfshuffler.py", line 429, in add_pdf_pages
w, h = page.get_size()
AttributeError: 'NoneType' object has no attribute 'get_size'

Hope this Helps,

Kaj

 

Last edit: Kaj Huisman 2013-06-07