I got this exception while generating PDF of my JFrame.

com.lowagie.text.exceptions.IllegalPdfSyntaxException: Unbalanced
save/restore state operators

Following is the code snipshot of generating pdf.

In that this is  the instance of Jframe

Document document = new Document();

try {

    //PdfWriter writer = PdfWriter.getInstance(document,new
FileOutputStream(f1.getSelectedFile()+".pdf"));

    PdfWriter writer = PdfWriter.getInstance(document,new
FileOutputStream("d:"+File.separator+"VIKAS_PDF"+File.separator+datewisefolder+".pdf"));

    document.open();

    PdfContentByte contentByte = writer.getDirectContent();



    PdfTemplate template = contentByte.createTemplate(690,850);

    Graphics2D g2 = template.createGraphics(680,840);

    this.print(g2);

    g2.dispose();

    contentByte.addTemplate(template,25,-37);


if(document.isOpen()){

     try{document.close();

     }

     catch(Exception
e){JOptionPane.showMessageDialog(this,e);System.out.println("In finally
"+e);

     }

    }
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to