How do I paint Swing Components to a PDF file with iText?

后端 未结 3 940
北恋
北恋 2020-12-19 10:34

I would like to print my Swing JComponent via iText to pdf.

JComponent com = new JPanel();
com.add( new JLabel(\"hello\") );

PdfWriter writer = PdfWriter.g         


        
相关标签:
3条回答
  • 2020-12-19 11:16

    I have figured it out adding addNotify and validate helps.

        com.addNotify( );
        com.validate( );
    
    0 讨论(0)
  • 2020-12-19 11:27

    I needed to call

    com.addNotify()
    com.setSize()
    com.validate()
    
    0 讨论(0)
  • 2020-12-19 11:30

    I don't know that much about iText, but... you did close the PdfWriter at some point, right?

    0 讨论(0)
提交回复
热议问题