Results 1 to 2 of 2
  1. #1
    sharmapiyush is offline Member
    Join Date
    Apr 2014
    Posts
    74
    Rep Power
    0

    Default print jpanel or convert to pdf

    can anyone tell me how to print a jpanel contents or is there any tool that can save the jpanel contents in pdf.
    i have tired using
    jpanel.printall();

    but that not working that gives an error as

    java code : -1074232

    something like that,

    Thanks

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: print jpanel or convert to pdf

    Hi,

    could you give the exact code that you tried? printAll needs an argument - what did you supply there?

    If you want to print your frame, then you should:
    Get a PrinterJob through PrinterJob.getPrinterJob();
    Then you can call printerJob.setPrintable(yourForm);
    Then calls to printDialog and print should be done.

    What happens is, that print is called. This is nice so you could use that method to
    - maybe set the background temporarily
    - scale the form so it fits on the page.
    And of course: The call of printAll is done in there to print the form to the given graphics instance.

    You can find examples on the internet. So one hit is java - How to print a JPanel with swing components? - Stack Overflow

    With kind regards,

    Konrad

Similar Threads

  1. print out jpanel
    By slamdon in forum AWT / Swing
    Replies: 1
    Last Post: 03-13-2013, 08:15 PM
  2. unable to print components in JPanel
    By raj.mscking@gmail.com in forum New To Java
    Replies: 9
    Last Post: 06-04-2012, 05:47 PM
  3. I would like to print this JPanel class. How?
    By AcousticBruce in forum New To Java
    Replies: 8
    Last Post: 02-26-2011, 06:25 PM
  4. print multiple jpanel
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 02-05-2010, 03:28 PM
  5. print jpanel
    By anilkumar_vist in forum New To Java
    Replies: 3
    Last Post: 01-08-2010, 12:08 PM

Posting Permissions

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