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
Xiaowu Zhang
erp5
Commits
a72fd424
Commit
a72fd424
authored
Dec 02, 2016
by
Tristan Cavelier
Committed by
Xiaowu Zhang
Aug 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XXX transform improvements wip (PDFDocument)
parent
3b666385
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
bt5/erp5_dms/DocumentTemplateItem/portal_components/document.erp5.PDFDocument.py
...mplateItem/portal_components/document.erp5.PDFDocument.py
+20
-3
No files found.
bt5/erp5_dms/DocumentTemplateItem/portal_components/document.erp5.PDFDocument.py
View file @
a72fd424
...
...
@@ -143,16 +143,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