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
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
Jérome Perrin
erp5
Commits
568a628a
Commit
568a628a
authored
Aug 07, 2023
by
Emmy Vouriot
Committed by
Jérome Perrin
Jun 14, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes to str when reading html or convert to text WIP
parent
f3fe05d1
Changes
1
Hide 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 @
568a628a
...
...
@@ -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