是否有一种确定的方法可以在应用程序中创建 PDF 或 MS Word 文档文件并立即通过电子邮件发送(也可能存储它)。
我已经尝试了一段时间并找到了JAVA库:apwlibrary和iText。但他们都不提供任何类型的教程。
有人能指出我正确的方向吗?
编辑:想一想,是否可以使用在线 PDF 生成器,首先将数据发送到服务,然后检索结果并将其保存在手机上?
Is there a definitive method of creating either a PDF or a MS Word Doc file within the app and email it immediately (and possibly, also store it).
I have been trying for quite some time and have found out the JAVA libraries: apwlibrary and iText. But both of them dont provide any tutorials of sorts.
Could anyone point me in the right direction?
EDIT: Come to think of it, is could an online PDF generator be used, first by sending the data to the service, then retrieve the result and save it on the phone?
发布评论
评论(4)
我推荐 apache fop http://xmlgraphics.apache.org/fop/
您可以使用标准 FOP 生成 pdf。
I would recommend apache fop http://xmlgraphics.apache.org/fop/
you can use standard FOP to generate pdf.
除非创建 pdf 文件是您设备的核心功能,否则我建议不要自己创建。添加 PDF 创建可能会需要大量工作,具体取决于您的性能需求。 Java 库将更容易添加,但性能较差。与 Java 相结合的本机库将更加难以维护构建和错误修复。
如果您只需要通过电子邮件发送一些信息,为什么不在 html 中创建消息文本并使用意图通过内置电子邮件程序通过电子邮件发送它呢?或者,如果您愿意,您可以将 PDF 生成放在服务器上,然后通过电子邮件发送链接。
Unless it is a core feature of your device to create a pdf file I would suggest not to do it yourself. Adding PDF creation is going to be quite a lot of work potentially depending on your performance needs. Java libraries will be easier to add but less performant. Native libraries combined with Java will be more hazzle to maintain build and bug fixing wise.
If you just need to email some information why dont you create a message text in html and use a intent to email it with the build in email program instead? Or if you want you could e.g. put the PDF generation on a server and just email a link..
我现在正在使用 JasperReports,这是一个开源库,用于用 Java 创建报告并将其导出为 PDF、DOC、XLS...将其与 iReport 结合使用来创建一组模板,可以非常轻松地创建填充的文件包含来自不同类型来源的内容(我正在使用 JavaBeans)。
如果您不喜欢静态模板的想法(根据您的需要,这有点烦人),您可以随时查看 DynamicJasper(网站上的示例很棒)。
祝你好运!
I'm working right now with JasperReports, an open source library to create reports in Java and export them to PDF, DOC, XLS... Using it in conjunction with iReport to create a group of templates makes it really easy to create files filled with content from different types of sources (I'm using JavaBeans).
If you don't like the idea of having static templates (That's a bit annoying depending on your needs), you can always take a look at DynamicJasper (The examples on the website are great).
Good Luck!
我使用过 Apache POI。看起来效果很好。 http://poi.apache.org/
实际上,http://poi.apache.org/hwpf/
I have used Apache POI. It seemed to work well. http://poi.apache.org/
This actually, http://poi.apache.org/hwpf/