Example usage for org.apache.pdfbox.tools TextToPDF createPDFFromText

List of usage examples for org.apache.pdfbox.tools TextToPDF createPDFFromText

Introduction

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

Prototype

public PDDocument createPDFFromText(Reader text) throws IOException 

Source Link

Document

Create a PDF document with some text.

Usage

From source file:com.validation.manager.core.tool.Tool.java

License:Apache License

public static File convertToPDF(File f, String filename) throws FileNotFoundException, IOException {
    TextToPDF ttp = new TextToPDF();
    File pdf;/*w w  w  .j  ava  2  s  .co m*/
    try (PDDocument pdfd = ttp.createPDFFromText(new FileReader(f))) {
        pdf = new File(filename);
        if (pdf.getParentFile() != null) {
            pdf.getParentFile().mkdirs();
        }
        pdfd.save(pdf);
    }
    pdf.deleteOnExit();
    return pdf;
}