Debian Codegraph @

war/src/main/webapp/highlight.jsp

raw
1 <%--
2 ! Licensed to the Apache Software Foundation (ASF) under one or more
3 ! contributor license agreements. See the NOTICE file distributed with
4 ! this work for additional information regarding copyright ownership.
5 ! The ASF licenses this file to You under the Apache License, Version 2.0
6 ! (the "License"); you may not use this file except in compliance with
7 ! the License. You may obtain a copy of the License at
8 !
9 ! http://www.apache.org/licenses/LICENSE-2.0
10 !
11 ! Unless required by applicable law or agreed to in writing, software
12 ! distributed under the License is distributed on an "AS IS" BASIS,
13 ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ! See the License for the specific language governing permissions and
15 ! limitations under the License.
16 --%>
17 <%@ page import="org.apache.pdfbox.pdmodel.PDDocument"%>
18 <%@ page import="org.apache.pdfbox.util.PDFHighlighter"%>
19 <%@ page import="java.net.URL"%>
20
21 <%
22 long start = System.currentTimeMillis();
23 response.setHeader("Cache-Control","no-cache") ;
24 response.setHeader("Pragma","no-cache") ;
25 response.setDateHeader("Expires",0);
26
27 String pdfURLString = request.getParameter( "pdf" );
28 String highlightWords = request.getParameter( "words" );
29
30 URL pdfURL = new URL( pdfURLString );
31 PDDocument doc = null;
32 try
33 {
34 doc = PDDocument.load( pdfURL.openStream() );
35 PDFHighlighter highlighter = new PDFHighlighter();
36 highlighter.generateXMLHighlight( doc, highlightWords.split( " " ), out );
37 }
38 finally
39 {
40 if( doc != null )
41 {
42 doc.close();
43 }
44 }
45 long stop = System.currentTimeMillis();
46 System.out.println( "Highlighter time:" +(stop-start) );
47 %>