Commit 7f704c1e authored by Jérome Perrin's avatar Jérome Perrin

PDF: don't fail getting content information when pdf is empty

parent ad84c4fa
......@@ -234,13 +234,10 @@ class PDFDocument(Image):
security.declareProtected(Permissions.AccessContentsInformation, 'getContentInformation')
def getContentInformation(self):
"""Returns the information about the PDF document with pdfinfo.
"""
Returns the information about the PDF document with
pdfinfo.
NOTE: XXX check that command exists and was executed
successfully
"""
if not self.hasData():
return dict()
try:
return self._content_information.copy()
except AttributeError:
......
......@@ -1323,6 +1323,12 @@ class TestDocument(TestDocumentMixin):
content_information = document.getContentInformation()
self.assertEquals('1', content_information['Pages'])
def test_empty_PDF_content_information(self):
document = self.portal.document_module.newContent(portal_type='PDF')
content_information = document.getContentInformation()
# empty PDF have no content information
self.assertEquals(dict(), content_information)
def test_PDF_content_content_type(self):
upload_file = makeFileUpload('REF-en-001.pdf')
document = self.portal.document_module.newContent(portal_type='PDF')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment