JPanel panel = new JPanel();

 com.lowagie.text.Document document = new com.lowagie.text.Document();
 PdfWriter writer = PdfWriter.getInstance(document, new
 FileOutputStream("ASEDG2D.pdf"));

 document.open();

 PdfContentByte cb = writer.getDirectContent();
 Graphics2D g2d = cb.createGraphics(PageSize.A4.width(),
 PageSize.A4.height());

 // The following line I wan't to replace by filling the g2d with
 // the Graphic of my existing JPanel: (Graphics2D) JPanel.getGraphics()
 // How can I do this?
 panel.paint(g2d);

 g2d.dispose();

 yes, it's that easy.

 Bill Ensley
 Bear Printing


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Bianca
> Sent: Friday, July 22, 2005 2:07 AM
> To: itext-questions@lists.sourceforge.net
> Subject: [iText-questions] SWT or Graphics/Graphics2D to PDF
>
>
> I just want to put my GUI (SWT) into a PDF, but I can't make it.Also can't
> find a hint in this mailinglist or on any other website... So somebody can
> help me?!
>
> I've got a JPanel, can get a Graphics or Graphics2D from it.
> I also know how to create a PdfContentByte and get a Graphics2d from it to
> draw in.
> But how can I get the Graphics2D of my JPanel to the PDFContentByte?
>
> JPanel panel = new JPanel();
>
> com.lowagie.text.Document document = new com.lowagie.text.Document();
> PdfWriter writer = PdfWriter.getInstance(document, new
> FileOutputStream("ASEDG2D.pdf"));
>
> document.open();
>
> PdfContentByte cb = writer.getDirectContent();
> Graphics2D g2d = cb.createGraphics(PageSize.A4.width(),
> PageSize.A4.height());
>
> // The following line I wan't to replace by filling the g2d with
> // the Graphic of my existing JPanel: (Graphics2D) JPanel.getGraphics()
> // How can I do this?
> g2d.drawString("text", 100, 100);
>
> g2d.dispose();
>
> document.close();
>
>
> Thanks!
> Bianca
>
> --
> GMX DSL = Maximale Leistung zum minimalen Preis!
> 2000 MB nur 2,99, Flatrate ab 4,99 Euro/Monat:
> http://www.gmx.net/de/go/dsl
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to