当我使用下面的代码将docx文件转换为pdf时,会生成一个空的pdf文件。任何人都可以帮我纠正这个问题。
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.poi.xwpf.converter.pdf.PdfConverter;
import org.apache.poi.xwpf.converter.pdf.PdfOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class ConversionDocxToPDF {
public static void main(String[] args) {
try {
InputStream is = new FileInputStream(new File("C:\\MtgMin.docx"));
XWPFDocument document = new XWPFDocument(is);
PdfOptions options = PdfOptions.create();
OutputStream out = new FileOutputStream(new File("C:\\MtgMin.pdf"));
PdfConverter.getInstance().convert(document, out, options);
} catch (Throwable e) {
e.printStackTrace();
}
}
}