[英]Converting dynamic XFA to static PDF
Requirement: View XFA based PDFs on mobile devices.要求:在移动设备上查看基于 XFA 的 PDF。
Options I've tried:我试过的选项:
Below is the sample code for print task.下面是打印任务的示例代码。 Adobe Acrobat DC is installed for 'Adobe PDF' print service.
为“Adobe PDF”打印服务安装了 Adobe Acrobat DC。
import java.awt.print.PrinterJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
...
private static void writePDF(long uid, Path path) throws Exception {
final String inFile = path.toString();
PDDocument pdfdoc = PDDocument.load(inFile);
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPageable(new PDPageable(pdfdoc));
// printJob.setPrintable(new PDPageable(pdfdoc));
printJob.setPrintService(getSystemPrinter("Adobe PDF"));
printJob.setJobName(path.getFileName().toString());
pdfdoc.silentPrint(printJob);
}
private static PrintService getSystemPrinter(final String printerName) {
PrintService desiredPrinter = null;
for (PrintService printer : PrintServiceLookup.lookupPrintServices(null, null)) {
if (printerName.equalsIgnoreCase(printer.getName())) {
desiredPrinter = printer;
break;
}
}
return desiredPrinter;
}
Someone please suggest a workaround to achieve the desired.有人请提出一种解决方法来实现所需的。 Thanks!
谢谢!
I solved it using free PDF Creator printer, configured to store files to some directory.我使用免费的 PDF Creator 打印机解决了这个问题,该打印机配置为将文件存储到某个目录。 Then I created a REST API to print XFA PDF and return PDF 1.4 to the API client.
然后我创建了一个 REST API 来打印 XFA PDF 并将 PDF 1.4 返回给 API 客户端。 It worked, but worked slow.
它有效,但工作缓慢。 Should say quality of resulted PDF is very well.
应该说结果 PDF 的质量非常好。
Also tried Adobe PDF and Microsoft Print to PDF printers through Ghostscript, but it prints only"Please wait..." page.还尝试通过 Ghostscript 将 Adobe PDF 和 Microsoft Print 打印到 PDF 打印机,但它只打印“请稍候...”页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.