Skip to content

Commit

Permalink
Fixed bug when pdf2txt didnt work and was returning null
Browse files Browse the repository at this point in the history
  • Loading branch information
judovana committed Feb 14, 2016
1 parent b34a5e3 commit 478ed88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Expand Up @@ -128,7 +128,7 @@ public void haders() {
out.println(" <input type=\"checkbox\" name=\"" + higlight + "\" value=\"true\" " + getCheckedHighlight() + "/> " + " Highlight. You must <b>rerun</b> the search(html only)" + "<br/>");
out.println(" <u>"+jump+" may lead to invisible part. Try adjust the number behind anchor <b>#</b>. You can check also individual tokens.</u><br/>");
out.println(" <input type=\"checkbox\" name=\"" + jump + "\" value=\"true\" " + getCheckedJump() + "/> " + " Jump to (first of) matches. You must <b>rerun</b> the search(html only)" + "<br/>");
out.println(" <input type=\"checkbox\" name=\"" + pdf2txt + "\" value=\"true\" " + getCheckedPdf2Text() + "/> " + " Allow jump and highlight in pdfs. You must <b>rerun</b> the search(html only)" + "<br/>");
out.println(" <input type=\"checkbox\" name=\"" + pdf2txt + "\" value=\"true\" " + getCheckedPdf2Text() + "/> " + " Allow jump and highlight in pdfs. You must <b>rerun</b> the search(pdf2txt)" + "<br/>");
out.println("</span>");
out.println("</span>");
//without submitbutton, the enter key do not work when more then one input type 'text' is presented
Expand Down
10 changes: 7 additions & 3 deletions src/javadocofflinesearch/server/TinyHttpdImpl.java
Expand Up @@ -184,15 +184,19 @@ public void run() {
buff = streamToBYteArray(decodingStream);
}

if (cmds.isHighlight() || cmds.isJump()) {
if (cmds.isHighlight() || cmds.isJump() || cmds.isPdf2txt()) {
String ll = potentionalFile.toLowerCase();
if (!ll.endsWith(".pdf") || cmds.isPdf2txt()) {
String s = decodedPdf;
if (s == null) {
s = new String(buff, "utf-8");
}
String highlighted = InfoExtractor.highlightInString(s, cmds.getQuery(), new StaticHtmlFormatter(null, null), cmds.isHighlight(), cmds.isJump(), potentionalFile.toLowerCase().endsWith(".html") || potentionalFile.toLowerCase().endsWith(".htm"));
buff = highlighted.getBytes("utf-8");
if (cmds.isHighlight() || cmds.isJump()) {
String highlighted = InfoExtractor.highlightInString(s, cmds.getQuery(), new StaticHtmlFormatter(null, null), cmds.isHighlight(), cmds.isJump(), potentionalFile.toLowerCase().endsWith(".html") || potentionalFile.toLowerCase().endsWith(".htm"));
buff = highlighted.getBytes("utf-8");
} else {
buff = s.getBytes("utf-8");
}
}

}
Expand Down

0 comments on commit 478ed88

Please sign in to comment.