Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
erp5
Commits
57cf5cdf
Commit
57cf5cdf
authored
Feb 26, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not raise error if PDF is not valid when searching for metadata
parent
57402c11
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
product/ERP5/Document/PDFDocument.py
product/ERP5/Document/PDFDocument.py
+13
-6
No files found.
product/ERP5/Document/PDFDocument.py
View file @
57cf5cdf
...
...
@@ -36,6 +36,7 @@ from Products.ERP5.Document.Image import Image
from
Products.ERP5.Document.Document
import
ConversionError
,
\
VALID_TEXT_FORMAT_LIST
from
subprocess
import
Popen
,
PIPE
from
zLOG
import
LOG
import
errno
class
PDFDocument
(
Image
):
...
...
@@ -269,16 +270,22 @@ class PDFDocument(Image):
# Then we use pyPdf to get extra metadata
try
:
from
pyPdf
import
PdfFileReader
from
pyPdf.utils
import
PdfReadError
except
ImportError
:
# if pyPdf not found, pass
pass
else
:
try
:
pdf_file
=
PdfFileReader
(
tmp
)
for
info_key
,
info_value
in
pdf_file
.
getDocumentInfo
().
iteritems
():
info_key
=
info_key
.
lstrip
(
"/"
)
if
isinstance
(
info_value
,
unicode
):
info_value
=
info_value
.
encode
(
"utf-8"
)
result
.
setdefault
(
info_key
,
info_value
)
except
PdfReadError
:
LOG
(
"PDFDocument.getContentInformation"
,
0
,
"pyPdf is Unable to read PDF, probably corrupted PDF here : %s"
%
\
(
self
.
getRelativeUrl
(),))
finally
:
tmp
.
close
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment