Results 1 to 7 of 7
  1. #1
    seredi is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default how to save a pdf file as named in a Jtextbox.

    I am writing a small standalone applicationwhere I need to save the report generated in pdf using Itext.

    1st part: I am using JtextBox in which
    users enters the name of village.

    2nd Part: and I want to automatically sa ve the pdf file as the name of t he village entered in Jtextbox.

    how to accomplish the 2nd part in itext?

    help needed.

    note:: no use of servlets. only a stand alone app.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: how to save a pdf file as named in a Jtextbox.

    How would you normally provide a filename to iText?
    However you do that, then simply get the String from the JTextBox and use that instead.

  3. #3
    seredi is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default dfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("example.pdf")

    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("example.pdf"));

    The above underlined "example.pdf" should be variable at runtime and should be able to be saved by desire of users.

    how to do?

  4. #4
    seredi is offline Member
    Join Date
    Sep 2011
    Posts
    14
    Rep Power
    0

    Default Re: how to save a pdf file as named in a Jtextbox.

    would u please post some write ups.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default Re: how to save a pdf file as named in a Jtextbox.

    I've never used iText, and I am not currently doing Swing, and I also tend not to post "teh codez".

    Find out how iText saves files (and weher it gets the name for the file from), then use the value in the text field instead...

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,257
    Rep Power
    19

    Default Re: how to save a pdf file as named in a Jtextbox.

    seredi, don't start more than one thread for the same question. I've merged your two threads here.

    db

  7. #7
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: how to save a pdf file as named in a Jtextbox.

    Since you know that the FileOutputStream is initialized with a String, just pass it the text inside the JTextField (which is a String).

    Java Code:
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(myTextField.getText()));

Similar Threads

  1. Complex GUI 60 JComboBox + 40+ JTextBox
    By Paul_White in forum New To Java
    Replies: 8
    Last Post: 05-12-2011, 07:51 PM
  2. Replies: 1
    Last Post: 10-08-2010, 02:19 AM
  3. Replies: 0
    Last Post: 03-05-2010, 04:21 AM
  4. Jtextbox with dropdown list
    By vijay_s in forum AWT / Swing
    Replies: 1
    Last Post: 05-08-2008, 10:17 PM
  5. Jtextbox with dropdown list
    By vijay_s in forum AWT / Swing
    Replies: 3
    Last Post: 05-08-2008, 06:26 AM

Tags for this Thread

Posting Permissions

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