Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
cloudooo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
cloudooo
Commits
b9d9540f
Commit
b9d9540f
authored
Apr 23, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdf: use pypdf >= 3.6.0
parent
ff27e154
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
cloudooo/handler/pdf/handler.py
cloudooo/handler/pdf/handler.py
+11
-9
setup.py
setup.py
+1
-1
No files found.
cloudooo/handler/pdf/handler.py
View file @
b9d9540f
...
...
@@ -36,11 +36,13 @@ from cloudooo.util import logger, parseContentType
from
subprocess
import
Popen
,
PIPE
from
tempfile
import
mktemp
from
pyPdf
import
PdfFileWriter
,
PdfFileReader
from
pyPdf.generic
import
NameObject
,
createStringObject
from
pypdf
import
PdfWriter
,
PdfReader
from
pypdf.generic
import
NameObject
,
createStringObject
@
implementer
(
IHandler
)
class
Handler
(
object
)
:
class
Handler
:
"""PDF Handler is used to handler inputed pdf document."""
def
__init__
(
self
,
base_folder_url
,
data
,
source_format
,
**
kw
):
...
...
@@ -94,8 +96,8 @@ class Handler(object):
metadata -- expected an dictionary with metadata.
"""
# TODO: date as "D:20090401124817-04'00'" ASN.1 for ModDate and CreationDate
input_pdf
=
Pdf
FileReader
(
open
(
self
.
document
.
getUrl
(),
"rb"
))
output_pdf
=
Pdf
File
Writer
()
input_pdf
=
Pdf
Reader
(
self
.
document
.
getUrl
(
))
output_pdf
=
PdfWriter
()
modification_date
=
metadata
.
pop
(
"ModificationDate"
,
None
)
if
modification_date
:
...
...
@@ -103,13 +105,13 @@ class Handler(object):
if
type
(
metadata
.
get
(
'Keywords'
,
None
))
is
list
:
metadata
[
'Keywords'
]
=
metadata
[
'Keywords'
].
join
(
' '
)
args
=
{}
for
key
,
value
in
list
(
metadata
.
items
()
):
for
key
,
value
in
metadata
.
items
(
):
args
[
NameObject
(
'/'
+
key
.
capitalize
())]
=
createStringObject
(
value
)
output_pdf
.
_info
.
get
O
bject
().
update
(
args
)
output_pdf
.
_info
.
get
_o
bject
().
update
(
args
)
for
page
_num
in
range
(
input_pdf
.
getNumPages
())
:
output_pdf
.
add
Page
(
input_pdf
.
getPage
(
page_num
)
)
for
page
in
input_pdf
.
pages
:
output_pdf
.
add
_page
(
page
)
output_stream
=
io
.
BytesIO
()
output_pdf
.
write
(
output_stream
)
...
...
setup.py
View file @
b9d9540f
...
...
@@ -12,7 +12,7 @@ install_requires = [
'zope.interface'
,
'PasteDeploy'
,
'PasteScript[WSGIUtils]'
,
'pyPdf'
,
'pyPdf
>=3.6.0
'
,
'psutil>=3.0.0'
,
'lxml'
,
'python-magic'
,
...
...
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