Quantcast

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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Yadhagiri Chilukuri

HI ,

I got this exception what are the situation came this exception :

 

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

 

give me sugetion  how to debug itext code when the have face this type of exceptions

 

I searched In but not find suitable answer.

 

 

Thanks & Regards Yadagiri Ch

Product Development

logo_new_emailsign.jpg

Global R&D Center: Napier Healthcare Solutions (India).Ltd,

3rd & 4th floor, Capella Block, Ascendas, Plot No. 17,

Software Units Layout, Madhapur, Hyderabad – 500 081.

Tel : +91 40 33557777, Fax : +91 40 30461844

URL : www.napierhealthcare.com

 

 

Disclaimer : This message (including attachment if any) is confidential and may be privileged. If you have received this message by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. E-mail may contain viruses. Before opening attachments please check them for viruses and defects. While Napier HealthcareSolutions India Ltd. (Napier) has put in place checks to minimize the risks, Napier will not be responsible for any viruses or defects or any forwarded attachments emanating either from within Napier or outside.
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
iText-questions mailing list
[hidden email]
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

iText mailing list
On 6/04/2012 7:13, Yadhagiri Chilukuri wrote:

HI ,

I got this exception what are the situation came this exception :

 

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

 

give me sugetion  how to debug itext code when the have face this type of exceptions

 

I searched In but not find suitable answer.

Search not further, just read the error message: you have unbalanced save/restore state operators.
In other words, somewhere you have used the method saveState() without using restoreState().
Or you have used restoreState() without using saveState().
Or maybe you have something like:

cb.saveState();
document.newPage();
cb.restoreState();

In older versions of iText, we allowed developers to write PDF syntax any which way they want.
Unfortunately, when you give this power to developers who didn't read and understand ISO-32000-1 (the standard you've probably read whilst searching for a suitable answer), you end up with PDFs that are corrupt. That's why we took away a little bit of that power. In order to make iText more "fool-proof", we now throw an exception when a developer doesn't respect the q/Q-rule.

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
iText-questions mailing list
[hidden email]
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
I am getting the same error when I try to add multiple PdfPTable objects to a document.

        doc.add(table1);
        doc.add(table2);
        doc.close();

The thread mentioned doing a cb.saveState() and a cb.restoreState().  What is "cb"??  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
In reply to this post by iText mailing list
I am getting the same error when I try to add multiple PdfPTable objects to a document.

        doc.add(table1);
        doc.add(table2);
        doc.close();

The thread mentioned doing a cb.saveState() and a cb.restoreState().  What is "cb"??  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
In reply to this post by iText mailing list
I am getting the same error when I try to add multiple PdfPTable objects to a document.

        doc.add(table1);
        doc.add(table2);
        doc.close();

The thread mentioned doing a cb.saveState() and a cb.restoreState().  What is "cb"??  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

iText mailing list
You are using a version that dates from at least July 2009.
You are experiencing a bug that has been fixed many years ago.
Please upgrade to a recent version of iText if you want to solve your
problem.


On Fri, 11 Dec 2015 06:40:27 -0800 (PST), glennr <[hidden email]> wrote:
> I am getting the same error when I try to add multiple PdfPTable objects
> to a
> document.
>
>         doc.add(table1);
>         doc.add(table2);
>         doc.close();
>
> The thread mentioned doing a cb.saveState() and a cb.restoreState().
What
> is "cb"??  Thanks.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
I'm not using an old version.  I downloaded version 5.5.8 last Thursday to upgrade from a really old version I was using.  When I downloaded new version 5.5.8 is when my problem started.  Please advise.  Thanks.


From: iText mailing list [via iText] <[hidden email]>
To: glennr <[hidden email]>
Sent: Saturday, December 12, 2015 5:09 AM
Subject: Re: com.lowagie.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators

You are using a version that dates from at least July 2009.
You are experiencing a bug that has been fixed many years ago.
Please upgrade to a recent version of iText if you want to solve your
problem.


On Fri, 11 Dec 2015 06:40:27 -0800 (PST), glennr <[hidden email]> wrote:
> I am getting the same error when I try to add multiple PdfPTable objects
> to a
> document.
>
>         doc.add(table1);
>         doc.add(table2);
>         doc.close();
>
> The thread mentioned doing a cb.saveState() and a cb.restoreState().
What
> is "cb"??  Thanks.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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



To unsubscribe from com.lowagie.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators, click here.
NAML


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
In reply to this post by iText mailing list
This is the stack trace I get if it helps.  Thanks

----------------
----------------
com.itextpdf.text.DocumentException: com.itextpdf.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators.
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:818)
at com.itextpdf.text.Document.add(Document.java:278)
at rpt.WarrantRpt.createReport(WarrantRpt.java:1656)
at rpt.ReportManager.writeReport(ReportManager.java:286)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at wcon.ConnectionServlet.process(ConnectionServlet.java:615)
at wcon.ConnectionServlet.doPost(ConnectionServlet.java:368)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.itextpdf.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators.
at com.itextpdf.text.pdf.PdfContentByte.sanityCheck(PdfContentByte.java:4155)
at com.itextpdf.text.pdf.PdfContentByte.reset(PdfContentByte.java:1794)
at com.itextpdf.text.pdf.PdfContentByte.reset(PdfContentByte.java:1782)
at com.itextpdf.text.pdf.PdfWriter.resetContent(PdfWriter.java:747)
at com.itextpdf.text.pdf.PdfDocument.endPage(PdfDocument.java:1058)
at com.itextpdf.text.pdf.PdfDocument.newPage(PdfDocument.java:939)
at com.itextpdf.text.pdf.PdfDocument.addPTable(PdfDocument.java:2729)
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:756)
... 18 more


From: iText mailing list [via iText] <[hidden email]>
To: glennr <[hidden email]>
Sent: Saturday, December 12, 2015 5:09 AM
Subject: Re: com.lowagie.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators

You are using a version that dates from at least July 2009.
You are experiencing a bug that has been fixed many years ago.
Please upgrade to a recent version of iText if you want to solve your
problem.


On Fri, 11 Dec 2015 06:40:27 -0800 (PST), glennr <[hidden email]> wrote:
> I am getting the same error when I try to add multiple PdfPTable objects
> to a
> document.
>
>         doc.add(table1);
>         doc.add(table2);
>         doc.close();
>
> The thread mentioned doing a cb.saveState() and a cb.restoreState().
What
> is "cb"??  Thanks.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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



To unsubscribe from com.lowagie.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators, click here.
NAML


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
In reply to this post by iText mailing list
This is the exception stack trace I get if it helps.
--------------
--------------
com.itextpdf.text.DocumentException: com.itextpdf.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators.
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:818)
at com.itextpdf.text.Document.add(Document.java:278)
at rpt.WarrantRpt.createReport(WarrantRpt.java:1656)
at rpt.ReportManager.writeReport(ReportManager.java:286)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at wcon.ConnectionServlet.process(ConnectionServlet.java:615)
at wcon.ConnectionServlet.doPost(ConnectionServlet.java:368)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.itextpdf.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators.
at com.itextpdf.text.pdf.PdfContentByte.sanityCheck(PdfContentByte.java:4155)
at com.itextpdf.text.pdf.PdfContentByte.reset(PdfContentByte.java:1794)
at com.itextpdf.text.pdf.PdfContentByte.reset(PdfContentByte.java:1782)
at com.itextpdf.text.pdf.PdfWriter.resetContent(PdfWriter.java:747)
at com.itextpdf.text.pdf.PdfDocument.endPage(PdfDocument.java:1058)
at com.itextpdf.text.pdf.PdfDocument.newPage(PdfDocument.java:939)
at com.itextpdf.text.pdf.PdfDocument.addPTable(PdfDocument.java:2729)
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:756)
... 18 more


From: "[hidden email]" <[hidden email]>
To: Post all your questions about iText here <[hidden email]>
Sent: Saturday, December 12, 2015 4:57 AM
Subject: Re: [iText-questions] com.lowagie.text.exceptions.IllegalPdfSyntaxException: Unbalanced save/restore state operators

You are using a version that dates from at least July 2009.
You are experiencing a bug that has been fixed many years ago.
Please upgrade to a recent version of iText if you want to solve your
problem.


On Fri, 11 Dec 2015 06:40:27 -0800 (PST), glennr <[hidden email]> wrote:
> I am getting the same error when I try to add multiple PdfPTable objects
> to a
> document.
>
>        doc.add(table1);
>        doc.add(table2);
>        doc.close();
>
> The thread mentioned doing a cb.saveState() and a cb.restoreState().
What
> is "cb"??  Thanks.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[hidden email]
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



------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

mkl
In reply to this post by glennr
glennr,
glennr wrote
I'm not using an old version.  I downloaded version 5.5.8 last Thursday to upgrade from a really old version I was using.  When I downloaded new version 5.5.8 is when my problem started.
You originally claimed:

On Fri, 11 Dec 2015 06:40:27 -0800 (PST), glennr wrote:
> I am getting the same error when I try to add multiple PdfPTable objects
> to a document.

in response to a message about a com.lowagie.text.exceptions.IllegalPdfSyntaxException - and if you indeed got a com.LOWAGIE.... exception, you ARE using a version that dates from at least July 2009.

If you merely did not read carefully what you responded to and actually got a com.ITEXTPDF.... exception, please share a runnable example

Regards,   Michael
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

glennr
Thanks for your quick response.

See attached example files with my report.  ReportManager is the main driver class that sets variables and makes the call to generate the warrant report.  This is a prototype so please excuse all the commented code of different things I am trying.

ReportManager.java
WarrantRpt.java
ReportPageEvent.java
mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

mkl
glennr wrote
See attached example files with my report.  ReportManager is the main driver class that sets variables and makes the call to generate the warrant report.  This is a prototype so please excuse all the commented code of different things I am trying.

ReportManager.java
WarrantRpt.java
ReportPageEvent.java
Unfortunately I cannot run that code, I cannot access your database and I do not have all the referenced classes.

Please share a Short, Self Contained, Compilable Example.

Regards,   Michael
Loading...