Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a761f269e |
@@ -470,39 +470,6 @@ class PDFExtractor:
|
|||||||
self.em.setfield("pdfannot", annotsfield)
|
self.em.setfield("pdfannot", annotsfield)
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def _patch_meta(self, html):
|
|
||||||
'''This fixes https://gitlab.freedesktop.org/poppler/poppler/-/issues/136'''
|
|
||||||
|
|
||||||
if not _mswindows:
|
|
||||||
pdfinfo = rclexecm.which("pdfinfo")
|
|
||||||
if not pdfinfo:
|
|
||||||
pdfinfo = rclexecm.which("poppler/pdfinfo")
|
|
||||||
|
|
||||||
if not pdfinfo:
|
|
||||||
return html
|
|
||||||
|
|
||||||
info = subprocess.check_output([pdfinfo, '-isodates', self.filename])
|
|
||||||
|
|
||||||
meta = {}
|
|
||||||
for line in info.split(b'\n'):
|
|
||||||
try:
|
|
||||||
key, value = line.strip().split(b':', 1)
|
|
||||||
meta[key.strip()] = value.strip().replace(b'"', b'\"')
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if b'CreationDate' in meta:
|
|
||||||
meta[b'date'] = meta[b'CreationDate']
|
|
||||||
|
|
||||||
title = meta.get('Title')
|
|
||||||
head = [b'<title>%s</title>' % title] if title else []
|
|
||||||
head += [ b'<meta name="%s" content="%s"/>' % x for x in meta.items() ]
|
|
||||||
|
|
||||||
start = html.index(b'<head>') + 6
|
|
||||||
end = html.index(b'</head>')
|
|
||||||
return html[:start] + b"".join(head) + html[end:]
|
|
||||||
|
|
||||||
|
|
||||||
def _selfdoc(self):
|
def _selfdoc(self):
|
||||||
'''Extract the text from the pdf doc (as opposed to attachment)'''
|
'''Extract the text from the pdf doc (as opposed to attachment)'''
|
||||||
self.em.setmimetype('text/html')
|
self.em.setmimetype('text/html')
|
||||||
@@ -516,8 +483,6 @@ class PDFExtractor:
|
|||||||
"UTF-8", "-eol", "unix", "-q",
|
"UTF-8", "-eol", "unix", "-q",
|
||||||
self.filename, "-"])
|
self.filename, "-"])
|
||||||
|
|
||||||
html = self._patch_meta(html)
|
|
||||||
|
|
||||||
html, isempty = self._fixhtml(html)
|
html, isempty = self._fixhtml(html)
|
||||||
#self.em.rclog("ISEMPTY: %d : data: \n%s" % (isempty, html))
|
#self.em.rclog("ISEMPTY: %d : data: \n%s" % (isempty, html))
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1598,7 +1598,9 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc)
|
|||||||
elt = elt.substr(0, 230);
|
elt = elt.substr(0, 230);
|
||||||
}
|
}
|
||||||
newdocument.add_posting(wrap_prefix(pathelt_prefix) + elt,
|
newdocument.add_posting(wrap_prefix(pathelt_prefix) + elt,
|
||||||
splitter.basepos + splitter.curpos++);
|
splitter.basepos + splitter.curpos);
|
||||||
|
newdocument.add_posting(elt,
|
||||||
|
splitter.basepos + splitter.curpos++);
|
||||||
}
|
}
|
||||||
splitter.basepos += splitter.curpos + 100;
|
splitter.basepos += splitter.curpos + 100;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user