Example usage for org.apache.pdfbox.tools PDFText2HTML PDFText2HTML

List of usage examples for org.apache.pdfbox.tools PDFText2HTML PDFText2HTML

Introduction

In this page you can find the example usage for org.apache.pdfbox.tools PDFText2HTML PDFText2HTML.

Prototype

public PDFText2HTML() throws IOException 

Source Link

Document

Constructor.

Usage

From source file:org.xwiki.test.misc.PDFTest.java

License:Open Source License

private String getPDFContent(URL url) throws Exception {
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    InputStream is = connection.getInputStream();
    PDDocument pdd = PDDocument.load(is);
    String text;//from w  w w  . jav a 2s.c  om
    try {
        PDFText2HTML stripper = new PDFText2HTML();
        text = stripper.getText(pdd);
    } finally {
        if (pdd != null) {
            pdd.close();
        }
        if (is != null) {
            is.close();
        }
    }
    return text;
}