Android Community
Results 1 to 10 of 10

Thread: Create a pdf file dynamically

  1. #1
    Join Date
    Sep 2010
    Posts
    9

    Default Create a pdf file dynamically


    hi
    I want to create a PDF file dynamically in android application.

    like File f = new File("sample.pdf");

    we have to use any external api for this? any idea?


    how can i do that?

    Thanks
    mindus

  2. #2
    Join Date
    Dec 2008
    Location
    Virginia
    Posts
    1,365

    Default Re: Create a pdf file dynamically

    Check out iText PDF -- it's free and fairly simple for generating pdf's.
    Phones: Nexus One (N1), and G1
    Android Developer & Linux Geek
    My Apps: Volume Locker | Shopriant - Shopping and Grocery Lists



  3. #3
    Join Date
    Nov 2009
    Posts
    72

    Default Re: Create a pdf file dynamically

    Quote Originally Posted by Scythe View Post
    Check out iText PDF -- it's free and fairly simple for generating pdf's.
    I second iText. I've used it in webapp projects for years.

  4. #4
    Join Date
    Sep 2010
    Posts
    9

    Default Re: Create a pdf file dynamically

    Hi
    Thanks for your reply.

    Does android supports iText? And google android accepts to include iText in the application?

    Because android has separate virtual machine (Dalvik) and it does not support all java classes.

    If it is supports can u please tell me how to proceed this?

    i tried this below sample code. But i got a error.

    f = new File(root, "hello.pdf");
    FileOutputStream file = new FileOutputStream(f);

    Document document = new Document();

    PdfWriter.getInstance(document, file);

    document.open();
    document.add(new Paragraph(result));

    document.close();
    file.close();

    The error is something related to some Color class in iText jar.


    Thanks
    mindus

  5. #5
    Join Date
    Sep 2010
    Posts
    9

    Default Re: Create a pdf file dynamically

    Hi,
    I found the solution and without using itext we can displaly pdf file.


    Thanks
    mindus

  6. #6
    Join Date
    Sep 2010
    Posts
    1

    Default Re: Create a pdf file dynamically

    Quote Originally Posted by mindus View Post
    Hi,
    I found the solution and without using itext we can displaly pdf file.


    Thanks
    mindus

    Hi mindus,
    I'm writing an app which need to output a pdf too.
    Could you tell me your solution? Did you use some other api?

    Thanks
    wanana

  7. #7
    Join Date
    Dec 2008
    Location
    Virginia
    Posts
    1,365

    Default Re: Create a pdf file dynamically

    Quote Originally Posted by mindus View Post
    Hi
    Thanks for your reply.

    Does android supports iText? And google android accepts to include iText in the application?

    Because android has separate virtual machine (Dalvik) and it does not support all java classes.

    If it is supports can u please tell me how to proceed this?

    i tried this below sample code. But i got a error.

    f = new File(root, "hello.pdf");
    FileOutputStream file = new FileOutputStream(f);

    Document document = new Document();

    PdfWriter.getInstance(document, file);

    document.open();
    document.add(new Paragraph(result));

    document.close();
    file.close();

    The error is something related to some Color class in iText jar.


    Thanks
    mindus
    Android just uses a different set of underlying code for compilation -- but it supports jar's fully.

  8. #8
    Join Date
    Sep 2010
    Posts
    9

    Default Re: Create a pdf file dynamically

    get the response using response.getEntity().getContent();

    It returns input stream and parse the input stream and get the value as a string.

    Create a pdf file like file f = new file("android.pdf");

    and write the result string in this android.pdf and using intent display it.

    By the way please create the file path like sdcard/download something like that.

    Using environment class u can get the path.

    Thanks
    mindus

  9. #9
    Join Date
    Jan 2011
    Posts
    2

    Default Re: Create a pdf file dynamically

    how to open existing PDF file in Android 2.2 Emulator through a path in C: drive /D drive/...

    please give me solution for this

  10. #10

    Default Re: Create a pdf file dynamically


    hey hi..
    I am Rachana, new to android. I am working on this loading pdf file. Can you tell me in detail how to do that? Actually I want to hardcore that pdf in code.
    Thanks,
    Rachana

Similar Threads

  1. dynamically assign drawable resource
    By kadmos in forum Developers Guild
    Replies: 3
    Last Post: 06-03-2010, 09:35 PM
  2. How to open a file in the file explorer application
    By asifk1234 in forum General Phone Chat
    Replies: 7
    Last Post: 05-06-2010, 07:31 AM
  3. How can I create an APN with DNS
    By argamusino in forum Developers Guild
    Replies: 1
    Last Post: 05-18-2009, 08:37 AM
  4. How to create XML
    By nas061000 in forum Developers Guild
    Replies: 0
    Last Post: 12-12-2008, 10:59 PM
  5. Wanted: dynamically updated/synched user photos
    By allthewhile in forum General Phone Chat
    Replies: 2
    Last Post: 11-22-2008, 01:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •