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
Tristan Cavelier
erp5
Commits
6892d346
Commit
6892d346
authored
Dec 02, 2016
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xxx transform improvements wip (PDFDocument)
parent
4e92e1e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
product/ERP5/Document/PDFDocument.py
product/ERP5/Document/PDFDocument.py
+20
-3
No files found.
product/ERP5/Document/PDFDocument.py
View file @
6892d346
...
...
@@ -142,16 +142,33 @@ class PDFDocument(Image):
data
=
self
.
_convertToDJVU
()
self
.
setConversion
(
data
,
mime
=
mime
,
format
=
'djvu'
)
return
(
mime
,
data
)
elif
format
in
(
''
,
None
,)
or
format
==
'pdf'
:
elif
format
in
(
''
,
None
,)
or
format
.
lower
()
==
'pdf'
:
# return original content
return
self
.
getContentType
(),
self
.
getData
()
el
se
:
el
if
format
.
lower
()
in
(
'png'
,
'jpg'
,
'jpeg'
,
'tif'
,
'tiff'
,
'gif'
,
'bmp'
,
'ico'
,
'svg'
,
'ppm'
,
'pcx'
)
:
if
kw
.
get
(
'frame'
,
None
)
is
None
:
# when converting to image from PDF we care for first page only
# this will make sure that only first page is used and not whole content of
# PDF file read & converted which is a performance issue
kw
[
'frame'
]
=
0
return
Image
.
_convert
(
self
,
format
,
**
kw
)
return
Image
.
_convert
(
self
,
format
.
lower
(),
**
kw
)
elif
"/"
in
format
:
data
=
self
.
getPortalObject
().
portal_transforms
.
convertToData
(
format
,
str
(
self
.
getData
()
or
""
),
context
=
self
,
mimetype
=
self
.
getContentType
())
if
data
is
None
:
raise
ConversionError
(
'PDFDocument conversion error. '
'portal_transforms failed to convert to %r: %r'
%
(
format
,
self
))
return
format
,
data
else
:
portal
=
self
.
getPortalObject
()
mimetype
=
portal
.
mimetypes_registry
.
lookupExtension
(
"a."
+
format
)
if
mimetype
is
None
:
raise
ConversionError
(
'PDFDocument conversion error. '
'mimetypes_registry failed to find mimetype of extension %r: %r'
%
(
format
,
self
))
data
=
portal
.
portal_transforms
.
convertToData
(
mimetype
,
str
(
self
.
getData
()
or
""
),
context
=
self
,
mimetype
=
self
.
getContentType
())
if
data
is
None
:
raise
ConversionError
(
'PDFDocument conversion error. '
'portal_transforms failed to convert to %r (%s): %r'
%
(
format
,
mimetype
,
self
))
return
mimetype
,
data
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'populateContent'
)
def
populateContent
(
self
):
...
...
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