Create PDF / Word (Doc) file within app
Solution 1
I would recommend apache fop http://xmlgraphics.apache.org/fop/ you can use standard FOP to generate pdf.
Solution 2
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..
Siddharth Lele
Updated on July 20, 2022Comments
-
Siddharth Lele almost 2 years
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?
-
Siddharth Lele over 13 yearsThanks for the prompt reply. Another thing though. Is there a guide or a tutorial that I can refer to?
-
Siddharth Lele over 13 years@Cristian: I dont think that guide will work as-is with Android would it?
-
Siddharth Lele over 13 yearsWell, 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.
-
Manfred Moser over 13 yearsCheck out the comments in code.google.com/p/k9mail/issues/detail?id=1980 and code.google.com/p/k9mail/issues/detail?id=2492 .. that works for me with html emails.
-
Siddharth Lele over 13 yearsI 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.
-
Manfred Moser over 13 yearsThe 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.
-
Omaita over 13 yearsummm, maybe I was too fast answering your question. These are Java libraries, I really don't know how things work with android (recompling maybe?).
-
Nishant over 13 yearsno. I used in a Java project. I thought you were looking for a Java lib to create a MS word file.
-
Siddharth Lele over 13 yearsEither PDF or that within my android app actually. The presentation of emails sent through the app is important.
-
Roman Soviak about 6 yearsYou should waste a lot of time on investigation for adding apache.poi lib to android studio project