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

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

Introduction

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

Prototype

public String getText(PDDocument doc) throws IOException 

Source Link

Document

This will return the text of a document.

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   www .  j  ava 2 s.  co  m*/
    try {
        PDFText2HTML stripper = new PDFText2HTML();
        text = stripper.getText(pdd);
    } finally {
        if (pdd != null) {
            pdd.close();
        }
        if (is != null) {
            is.close();
        }
    }
    return text;
}