A BT without a matching ET is an error.  If you have any other operators than 
those allowed inside BT/ET, it's an error.

Leonard

From: Mark Storer [mailto:msto...@autonomy.com]
Sent: Monday, August 30, 2010 2:17 PM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Error: Unbalanced begin/end 
textoperatorssinceiText 5

Somewhere in your program, you've always had an unbalanced number of BT/ET 
pairs.  If you take one of your old PDFs (that was built by the older 
iTextSharp) and run it through Acrobat Pro's syntax checker, you'll find you 
have a problem.  Adobe's smart enough to Figure It Out, but there are quite a 
few other PDF viewers floating around these days that are not.

That's why I added the code to catch the unbalanced pairs, and why the rest of 
the team agreed that it was a good idea.  IIRC, the same sort of error is 
thrown with unbalanced q/Q pairs, though the verbage may be different...

And now I can't find where I put the check for BT/ET...

Ah yes... sanityCheck().  And because it's throwing during a newPage(), that 
means you have a BT without an ET somewhere in your page's text stream.  Not in 
the direct content, and changing that won't affect the text ContentByte one way 
or the other.

It's technically possible that we are throwing in error.  For Example:

q
  BT
   (blah)Tj
Q

I'm not sure how the PDF spec handles this Weird Case, or even if it has 
anything to say on the matter.  Lets see...

"A text object begins with the BT operator and ends with the ET operator, as 
shown in the Example, and described in Table 107. "

So the above content example is either illegal, or still inside a text object 
after the Q.  We're fiine... but there's some wiggle room here in the spec that 
makes me uncomfortable.  "Alarmed" even.  Leonard, am I reading this right?

Text state is also kinda independant of the regular graphic state.  Text 
attributes within a BT/ET pair are local to that text object.  BT/ET is kind of 
text's version of q/Q.  I would therefore hope that q BT Q parses as an 
unclosed text object, but a retentive reading of the quoted line would make q 
BT Q ET legal... like I said, "alarming".  I'm poking around in the q/Q verbage 
for something to support/reject this interpretation, to no avail.

These operators have been around since PDF 1.0... I'd be shocked if this 
question hasn't come up before.


--Mark Storer
  Senior Software Engineer
  Cardiff.com

import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;



________________________________
From: Paulo Soares [mailto:psoa...@glintt.com]
Sent: Monday, August 30, 2010 9:16 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Error: Unbalanced begin/end 
textoperatorssinceiText 5
The only problem I can see here is that you are still ignoring the request for 
a simple, complete, standalone example. I'm ok you that, it's your problem, not 
mine.

Paulo
----- Original Message -----
From: alrts<mailto:edition-b...@swissonline.ch>
To: 
itext-questions@lists.sourceforge.net<mailto:itext-questions@lists.sourceforge.net>
Sent: Monday, August 30, 2010 4:59 PM
Subject: Re: [iText-questions] Error: Unbalanced begin/end text 
operatorssinceiText 5


Referring back to my first example with ColumnText(), the internal buffer of
the ColumnText ct reads just before the document is closed:

Canvas = {BT
1 0 0 1 163.67 479.06 Tm
/F1 26 Tf
(Astrologisches Porträt)Tj
ET
}

This looks pretty much ok, BT being short for BeginText(), then comes the
SetSimpleColumn(...), followed by the phrase (preceded by the chunk's font)
and ET for endText(). But, upon CloseDocument() the

Unbalanced begin/end text operators

error appears. Can anybody see a problem here ?

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.851 / Virus Database: 271.1.1/3091 - Release Date: 08/29/10 
11:34:00
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to