10

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?

Shruti
  • 1
  • 13
  • 55
  • 95
Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151

4 Answers4

2

I would recommend apache fop http://xmlgraphics.apache.org/fop/ you can use standard FOP to generate pdf.

HamoriZ
  • 2,370
  • 18
  • 38
1

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..

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
  • Well, the app in question is to create quotes / proposals and the idea is to let the user send as good looking emails to their clients as possible. I am currently using the inbuilt email as you rightly suggest, but it is not the best looking solution. I assumed that creating a PDF with the option of letting the user attach his logo, etc would make it a better proposition. That said, could you point me to some example of sending an HTML email? Perhaps, that could take care of the requirements temporarily. – Siddharth Lele Dec 21 '10 at 05:00
  • Check out the comments in http://code.google.com/p/k9mail/issues/detail?id=1980 and http://code.google.com/p/k9mail/issues/detail?id=2492 .. that works for me with html emails. – Manfred Moser Dec 21 '10 at 05:10
  • I looked up a few pages for sending an HTML email and it still looks kinda shabby. Far from professional. How about the other suggestion? Any tips on that? The PDF on a server and sending the link part. – Siddharth Lele Dec 21 '10 at 09:28
  • The email part is the same and on the server side you got a world of choice with various platforms (php, java, rails whatever you like). In the Java world a couple of web frameworks support PDF generation (e.g. Seam) and there are full on reporting frameworks with UI tools and so (e.g. JasperServer).. it depends on what you already have to some extend. – Manfred Moser Dec 21 '10 at 16:46
0

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!

Omaita
  • 1
  • ummm, maybe I was too fast answering your question. These are Java libraries, I really don't know how things work with android (recompling maybe?). – Omaita Dec 22 '10 at 11:09
0

I have used Apache POI. It seemed to work well. http://poi.apache.org/

This actually, http://poi.apache.org/hwpf/

Nishant
  • 54,584
  • 13
  • 112
  • 127