Search in sources :

Example 1 with PdfOptions

use of org.apache.poi.xwpf.converter.pdf.PdfOptions in project Gargoyle by callakrsos.

the class PDFUtil method convert.

/**
	 * @작성자 : KYJ
	 * @작성일 : 2017. 3. 3.
	 * @param docxFile
	 * @param outPdfFile
	 * @throws FileNotFoundException
	 * @throws IOException
	 */
public static void convert(XWPFDocument document, File outPdfFile) throws FileNotFoundException, IOException {
    try (OutputStream out = new FileOutputStream(outPdfFile)) {
        PdfOptions options = PdfOptions.getDefault();
        PdfConverter.getInstance().convert(document, out, options);
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) PdfOptions(org.apache.poi.xwpf.converter.pdf.PdfOptions)

Example 2 with PdfOptions

use of org.apache.poi.xwpf.converter.pdf.PdfOptions in project Gargoyle by callakrsos.

the class MSWordTest method toPdf.

@Test
public final void toPdf() throws FileNotFoundException, IOException {
    File file = new File("C:\\Users\\KYJ\\Desktop\\학습\\Algorism.docx");
    XWPFDocument document = new XWPFDocument(new FileInputStream(file));
    File outFile = new File("Algorism.pdf");
    try (OutputStream out = new FileOutputStream(outFile)) {
        PdfOptions options = PdfOptions.getDefault();
        PdfConverter.getInstance().convert(document, out, options);
    }
    System.out.println("Sucess");
    FileUtil.openFile(outFile);
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) PdfOptions(org.apache.poi.xwpf.converter.pdf.PdfOptions) XWPFDocument(org.apache.poi.xwpf.usermodel.XWPFDocument) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 PdfOptions (org.apache.poi.xwpf.converter.pdf.PdfOptions)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 XWPFDocument (org.apache.poi.xwpf.usermodel.XWPFDocument)1 Test (org.junit.Test)1