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
138
Merge Requests
138
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
a57b339b
Commit
a57b339b
authored
Aug 07, 2023
by
Emmy Vouriot
Committed by
Arnaud Fontaine
Jul 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes to str when reading html or convert to text WIP
parent
0cdbce12
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 @
a57b339b
...
@@ -194,7 +194,7 @@ class PDFDocument(Image):
...
@@ -194,7 +194,7 @@ class PDFDocument(Image):
context
=
self
,
filename
=
filename
,
context
=
self
,
filename
=
filename
,
mimetype
=
self
.
getContentType
())
mimetype
=
self
.
getContentType
())
if
result
:
if
result
:
return
result
return
bytes2str
(
result
)
else
:
else
:
# Try to use OCR from ghostscript, but tolerate that the command might
# Try to use OCR from ghostscript, but tolerate that the command might
# not be available.
# not be available.
...
@@ -282,7 +282,7 @@ class PDFDocument(Image):
...
@@ -282,7 +282,7 @@ class PDFDocument(Image):
command
=
[
'pdftohtml'
,
'-enc'
,
'UTF-8'
,
'-stdout'
,
command
=
[
'pdftohtml'
,
'-enc'
,
'UTF-8'
,
'-stdout'
,
'-noframes'
,
'-i'
,
tmp
.
name
]
'-noframes'
,
'-i'
,
tmp
.
name
]
try
:
try
:
command_result
=
Popen
(
command
,
stdout
=
PIPE
).
communicate
()[
0
]
command_result
=
bytes2str
(
Popen
(
command
,
stdout
=
PIPE
).
communicate
()[
0
])
except
OSError
as
e
:
except
OSError
as
e
:
if
e
.
errno
==
errno
.
ENOENT
:
if
e
.
errno
==
errno
.
ENOENT
:
raise
ConversionError
(
'pdftohtml was not found'
)
raise
ConversionError
(
'pdftohtml was not found'
)
...
@@ -291,10 +291,10 @@ class PDFDocument(Image):
...
@@ -291,10 +291,10 @@ class PDFDocument(Image):
finally
:
finally
:
tmp
.
close
()
tmp
.
close
()
# Quick hack to remove bg color - XXX
# 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
# Make links relative
h
=
h
.
replace
(
str2bytes
(
'href="%s.html'
%
tmp
.
name
.
split
(
os
.
sep
)[
-
1
])
,
h
=
h
.
replace
(
'href="%s.html'
%
tmp
.
name
.
split
(
os
.
sep
)[
-
1
]
,
b
'href="asEntireHTML'
)
'href="asEntireHTML'
)
return
h
return
h
security
.
declarePrivate
(
'_convertToDJVU'
)
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