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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
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
...
@@ -36,6 +36,7 @@ from Products.ERP5.Document.Image import Image
from
Products.ERP5.Document.Document
import
ConversionError
,
\
from
Products.ERP5.Document.Document
import
ConversionError
,
\
VALID_TEXT_FORMAT_LIST
VALID_TEXT_FORMAT_LIST
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
from
zLOG
import
LOG
import
errno
import
errno
class
PDFDocument
(
Image
):
class
PDFDocument
(
Image
):
...
@@ -269,16 +270,22 @@ class PDFDocument(Image):
...
@@ -269,16 +270,22 @@ class PDFDocument(Image):
# Then we use pyPdf to get extra metadata
# Then we use pyPdf to get extra metadata
try
:
try
:
from
pyPdf
import
PdfFileReader
from
pyPdf
import
PdfFileReader
from
pyPdf.utils
import
PdfReadError
except
ImportError
:
except
ImportError
:
# if pyPdf not found, pass
# if pyPdf not found, pass
pass
pass
else
:
else
:
try
:
pdf_file
=
PdfFileReader
(
tmp
)
pdf_file
=
PdfFileReader
(
tmp
)
for
info_key
,
info_value
in
pdf_file
.
getDocumentInfo
().
iteritems
():
for
info_key
,
info_value
in
pdf_file
.
getDocumentInfo
().
iteritems
():
info_key
=
info_key
.
lstrip
(
"/"
)
info_key
=
info_key
.
lstrip
(
"/"
)
if
isinstance
(
info_value
,
unicode
):
if
isinstance
(
info_value
,
unicode
):
info_value
=
info_value
.
encode
(
"utf-8"
)
info_value
=
info_value
.
encode
(
"utf-8"
)
result
.
setdefault
(
info_key
,
info_value
)
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
:
finally
:
tmp
.
close
()
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