Hi Bruno,

thanks for replying.

I've tried doing it the below way, but cannot create the PDF successfully. When I tried to open the PDF created, the message that is returned is:
"There was an error opening this document. This file is already open or in use by another application."

try{
    com.lowagie.text.Document document1 = new com.lowagie.text.Document(PageSize.A4, 80, 50, 30, 65);
    PdfWriter writer = PdfWriter.getInstance(document1, new FileOutputStream("test.pdf"));
    document1.open();
    PdfContentByte cb = writer.getDirectContent();
    cb.saveState();
    DefaultFontMapper mapper = new DefaultFontMapper();
   
    PdfGraphics2D g2 = (PdfGraphics2D)cb.createGraphics(612, 792, mapper);
   
    mainPane.paint(g2);
    g2.dispose();
    document1.close();
    writer.close();
    }catch (Exception e){
            System.err.print( e.getMessage());
    }

Can you help? Thanks!

Dorothy




bruno <[EMAIL PROTECTED]>

14/06/2006 05:24 PM

To
Post all your questions about iText here <[email protected]>, Dorothy NG/OPS/AH/[EMAIL PROTECTED]
cc
Subject
Re: [iText-questions] Creating PDF using JEditorPane





[EMAIL PROTECTED] wrote:

>
> Hi,
>
> may I know if it's possible to create PDF using jEditorPane?

JEditorPane has a method paint(Graphics g);
com.lowagie.text.pdf.PdfGraphics2D implements the Graphics interface.
Just create a PdfGraphics2D instance and
let the editor pane paint itself to this instance.
br,
Bruno

_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to