Create PDF / Word (Doc) file within app

16,501

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

Share:
16,501
Siddharth Lele
Author by

Siddharth Lele

Updated on July 20, 2022

Comments

  • Siddharth Lele
    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
    Siddharth Lele over 13 years
    Thanks for the prompt reply. Another thing though. Is there a guide or a tutorial that I can refer to?
  • Siddharth Lele
    Siddharth Lele over 13 years
    @Cristian: I dont think that guide will work as-is with Android would it?
  • Siddharth Lele
    Siddharth Lele over 13 years
    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.
  • Manfred Moser
    Manfred Moser over 13 years
    Check 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
    Siddharth Lele over 13 years
    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.
  • Manfred Moser
    Manfred Moser over 13 years
    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.
  • Omaita
    Omaita over 13 years
    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?).
  • Nishant
    Nishant over 13 years
    no. I used in a Java project. I thought you were looking for a Java lib to create a MS word file.
  • Siddharth Lele
    Siddharth Lele over 13 years
    Either PDF or that within my android app actually. The presentation of emails sent through the app is important.
  • Roman Soviak
    Roman Soviak about 6 years
    You should waste a lot of time on investigation for adding apache.poi lib to android studio project