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
Titouan Soulard
erp5
Commits
31dfcae9
Commit
31dfcae9
authored
Aug 07, 2023
by
Emmy Vouriot
Committed by
Jérome Perrin
Aug 21, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes to str when reading html or convert to text WIP
parent
915df9f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
bt5/erp5_dms/DocumentTemplateItem/portal_components/document.erp5.PDFDocument.py
...mplateItem/portal_components/document.erp5.PDFDocument.py
+5
-5
No files found.
bt5/erp5_dms/DocumentTemplateItem/portal_components/document.erp5.PDFDocument.py
View file @
31dfcae9
...
...
@@ -194,7 +194,7 @@ class PDFDocument(Image):
context
=
self
,
filename
=
filename
,
mimetype
=
self
.
getContentType
())
if
result
:
return
result
return
bytes2str
(
result
)
else
:
# Try to use OCR from ghostscript, but tolerate that the command might
# not be available.
...
...
@@ -282,7 +282,7 @@ class PDFDocument(Image):
command
=
[
'pdftohtml'
,
'-enc'
,
'UTF-8'
,
'-stdout'
,
'-noframes'
,
'-i'
,
tmp
.
name
]
try
:
command_result
=
Popen
(
command
,
stdout
=
PIPE
).
communicate
()[
0
]
command_result
=
bytes2str
(
Popen
(
command
,
stdout
=
PIPE
).
communicate
()[
0
])
except
OSError
as
e
:
if
e
.
errno
==
errno
.
ENOENT
:
raise
ConversionError
(
'pdftohtml was not found'
)
...
...
@@ -291,10 +291,10 @@ class PDFDocument(Image):
finally
:
tmp
.
close
()
# Quick hack to remove bg color - XXX
h
=
command_result
.
replace
(
b'<BODY bgcolor="#A0A0A0"'
,
b
'<BODY '
)
h
=
command_result
.
replace
(
'<BODY bgcolor="#A0A0A0"'
,
'<BODY '
)
# Make links relative
h
=
h
.
replace
(
str2bytes
(
'href="%s.html'
%
tmp
.
name
.
split
(
os
.
sep
)[
-
1
])
,
b
'href="asEntireHTML'
)
h
=
h
.
replace
(
'href="%s.html'
%
tmp
.
name
.
split
(
os
.
sep
)[
-
1
]
,
'href="asEntireHTML'
)
return
h
security
.
declarePrivate
(
'_convertToDJVU'
)
...
...
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