我正在尝试将docx文件转换为PDF,但是此文件仅包含在转换过程中无法识别的插入文本(docx或document4j)。
有人可以帮我找到一个lib或任何提示吗?
谢谢。
try {
InputStream in = testXdocReportDoc.class.getResourceAsStream("testXdocReportDoc.docx");
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in, TemplateEngineKind.Velocity);
IContext context = report.createContext();
Project project = new Project("test1", "test2", "test3", "test4", "test5");
context.put("project", project);
File tempFile = new File(f.getAbsolutePath().replace("pdf", "docx"));
OutputStream out = new FileOutputStream(tempFile);
report.process(context, out);
try {
String inputFile = tempFile.getAbsolutePath();
FileInputStream in2 = new FileInputStream(inputFile);
XWPFDocument document = new XWPFDocument(in2);
OutputStream out2 = new FileOutputStream(f);
PdfOptions options = null;
PdfConverter.getInstance().convert(document, out2, options);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}