File: highlight.jsp

package info (click to toggle)
libpdfbox-java 1%3A0.7.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 27,316 kB
  • ctags: 18,061
  • sloc: java: 38,032; xml: 2,650; sh: 48; jsp: 27; makefile: 12
file content (31 lines) | stat: -rw-r--r-- 964 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<%@ page import="org.pdfbox.pdmodel.PDDocument"%>
<%@ page import="org.pdfbox.util.PDFHighlighter"%>
<%@ page import="java.net.URL"%>

<%
    long start = System.currentTimeMillis();
    response.setHeader("Cache-Control","no-cache") ;
    response.setHeader("Pragma","no-cache") ;
    response.setDateHeader("Expires",0);

    String pdfURLString = request.getParameter( "pdf" );
    String highlightWords = request.getParameter( "words" );
    
    URL pdfURL = new URL( pdfURLString );
    PDDocument doc = null;
    try
    {
        doc = PDDocument.load( pdfURL.openStream() );
        PDFHighlighter highlighter = new PDFHighlighter();
        highlighter.generateXMLHighlight( doc, highlightWords.split( " " ), out );
    }
    finally
    {
        if( doc != null )
        {
            doc.close();
        }
    }
    long stop = System.currentTimeMillis();
    System.out.println( "Highlighter time:" +(stop-start) );
%>