List of usage examples for org.apache.pdfbox.tools TextToPDF createPDFFromText
public PDDocument createPDFFromText(Reader text) throws IOException
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; }