Create a simple test case that can be run standalone. The code you have
should work because setFontAndSize() is a text state that can be used at
the page description level.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Darryl Miles
> Sent: Wednesday, May 17, 2006 1:09 PM
> To: [email protected]
> Subject: Re: [iText-questions] Storing a PdfContentByte state ?
> 
> Paulo Soares wrote:
> > PdfContentByte.saveState() saves everything including the 
> font, matrix,
> > colors, etc.
> 
> Hmm... ok, I get unexpected output (when viewed from Acrobat 
> 7.0.7) if I 
> don't explicitly reset the PdfContentByte.setFontAndSize() at 
> a point I 
> expected restoreState() to have reset the font back to what 
> is was before.
> 
> 
> My innerMethod function is actually an implementation of 
> SMALL CAPS for 
> lowercased characters of the passed string, but I have 
> simplified it in 
> this example.
> 
> 
> Code goes something like:
> 
> 
> public void outerMethod(PdfContentByte cb, BaseFont font) {
>   cb.setFontAndSize(font.getBaseFont(), 8);
> 
>   innerMethod(cb, font.getBaseFont(), 
> PdfContentByte.ALIGN_RIGHT, 8, 6, 
> "abcDEF", colOneIndentX, thisLineY, 0);
> cb.setFontAndSize(font.getBaseFont(), 8);     // Restore font 
> info from 
> calling #innerMethod() this is the call I'm not expecting to 
> need to make
> 
>   cb.beginText();
>   // This is the text that which ends up in the wrong place, 
> by around 
> 6pts east when a 6pt/smallSize font got selected inside innerMethod
>   cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "Some Data", 
> colTwoIndentX, thisLineY, 0);
>   cb.endText();
> }
> 
> 
> public void innerMethod(PdfContentByte cb, BaseFont baseFont, 
> int align, 
> float bigSize, float smallSize, String s, float x, float y, float a) {
>   cb.saveState();
>   cb.beginText();
>   float fontSize = bigSize;
>   if(Ctype.islower(s.charAt(0)))
>    fontSize = smallSize;
>   float charSpacing = 1.0f;
>   cb.moveText(x, y);  // Simplyfied example of ALIGN_LEFT
>   cb.setFontAndSize(baseFont, fontSize);
>   cb.setCharacterSpacing(charSpacing);
>   cb.showText(s.charAt(0));
>   cb.endText();
>   cb.restoreState();
> }
> 
> 
> Maybe there is somewhere I can attach a test case if anyone is 
> interested.  For now I just make the extra call to 
> cb.setFontAndSize() 
> after any call to innerMethod().
> 
> 
> 
> Adding:
> 
> cb.beginText();
> cb.endText();
> 
> after the first cb.setFontAndSize() also fixes the output to what I 
> expect.  I can't do saveState() after beginText() I get an 
> error/warning 
> in acrobat.
> 
> Maybe a "setfont" isn't called until cb.beginText(), which means the 
> graphics state is not setup.  I'm not sure what iText's goals are 
> aligning with PDF/PS syntax or being programtically intuitive.
> 
> 
> Thanks for your clarification,
> 
> Darryl
> 
> 
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web 
> services, security?
> Get stuff done quickly with pre-integrated technology to make 
> your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on 
> Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&;
> dat=121642
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to