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
Hamza
erp5
Commits
57402c11
Commit
57402c11
authored
Feb 25, 2013
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use pyPdf instead of pdftk to extract non standard metadata from pdf
parent
50e1a93a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
20 deletions
+11
-20
product/ERP5/Document/PDFDocument.py
product/ERP5/Document/PDFDocument.py
+11
-20
No files found.
product/ERP5/Document/PDFDocument.py
View file @
57402c11
...
@@ -266,28 +266,19 @@ class PDFDocument(Image):
...
@@ -266,28 +266,19 @@ class PDFDocument(Image):
value
=
':'
.
join
(
item_list
[
1
:]).
strip
()
value
=
':'
.
join
(
item_list
[
1
:]).
strip
()
result
[
key
]
=
value
result
[
key
]
=
value
# Then we use p
dftk
to get extra metadata
# Then we use p
yPdf
to get extra metadata
try
:
try
:
command
=
[
'pdftk'
,
tmp
.
name
,
'dump_data'
,
'output'
]
from
pyPdf
import
PdfFileReader
command_result
=
Popen
(
command
,
stdout
=
PIPE
).
communicate
()[
0
]
except
ImportError
:
except
OSError
,
e
:
# if pyPdf not found, pass
# if pdftk not found, pass
pass
if
e
.
errno
!=
errno
.
ENOENT
:
raise
else
:
else
:
line_list
=
(
line
for
line
in
command_result
.
splitlines
())
pdf_file
=
PdfFileReader
(
tmp
)
while
True
:
for
info_key
,
info_value
in
pdf_file
.
getDocumentInfo
().
iteritems
():
try
:
info_key
=
info_key
.
lstrip
(
"/"
)
line
=
line_list
.
next
()
if
isinstance
(
info_value
,
unicode
):
except
StopIteration
:
info_value
=
info_value
.
encode
(
"utf-8"
)
break
result
.
setdefault
(
info_key
,
info_value
)
if
line
.
startswith
(
'InfoKey'
):
key
=
line
[
len
(
'InfoKey: '
):]
line
=
line_list
.
next
()
assert
line
.
startswith
(
'InfoValue: '
),
\
"Wrong format returned by pdftk dump_data"
value
=
line
[
len
(
'InfoValue: '
):]
result
.
setdefault
(
key
,
value
)
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