On 30/06/2011 19:54, Crag Markwood wrote:
> Hello,
> I'm adding a template and need to set the font. I would like to get the 
> existing font from PdfContentByte (pcb below) but the pcb.state is protected. 
> How can I access it?

You can't and you shouldn't.
Let's take a look at your example:
>          PdfTemplate template = pcb.createTemplate(w, h);
>          template.beginText();
>          template.setFontAndSize(font, 9);
>          template.showText(text);
>          template.endText();

In this template, you create PDF syntax and you use the Tf operator to 
set the font and size.
This Tf operator is a "text state" operator. It's illegal and useless 
outside a BT/ET text block.
Not that creating a BT/ET block and showing text WITHOUT the Tf operator 
is illegal too.
That's why you correctly put setFontAndSize() inside a beginText() and 
endText() sequence.

All other Tf operators outside the BT/ET sequence are irrelevant.
If you've set a different font and size outside this "template", they 
won't affect the content of the template.
Therefore asking the pcb object for its font and size doesn't make sense.
If a Tf operator was present at some point, it was present inside a 
CLOSED BT/ET sequence, before:

>        pcb.addTemplate(template, xScale, xRote, yRote, yScale, x, y);

I'm 99% sure that's not the answer you wanted.
You should read this answer as the technical explanation why I don't 
understand your question.
Please clarify: why do you need a font you've used in a PdfContentByte 
object before.
What makes you think this is a font? (There doesn't have to be one!)
What makes you think there is only one font? (There could be many!)

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
iText-questions mailing list
[email protected]
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