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

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

Introduction

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

Prototype

TextToPDF

Source Link

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;//from   w w  w . jav  a2 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;
}