It's done in the html:
<font face="times-roman">Look at me!</font>
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of [EMAIL PROTECTED]
> Sent: Thursday, September 07, 2006 3:42 PM
> To: [email protected]
> Subject: [iText-questions] How to set font for text using ColumnText?
>
>
>
> Hi list,
>
> i can't seem to force a certain font and font size to be
> active when adding text directly to a PDF. I have tried the
> following code (below). Whatever i do, the font used in the
> pdf is always Arial 12.
>
> Please advice
>
> kind regards
>
> Daniel
>
>
> HTMLWorker worker =
> new HTMLWorker(document);
> StyleSheet style =
> new StyleSheet(); // stylesheet
> loadStyles( style );
>
>
> StringReader sr = new
> StringReader( fieldValue );
> ArrayList array =
> HTMLWorker.parseToList(sr,style);
>
> float[] position =
> af.getFieldPositions( bodyFieldName );
>
> int n =
> reader.getNumberOfPages();
> // we retrieve the
> size of the first page
> Rectangle psize =
> reader.getPageSize(1);
> float width = psize.height();
> float height = psize.width();
>
>
> PdfContentByte cb =
> stp.getOverContent((int)position[0]);
> BaseFont bf =
> BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252,
> BaseFont.NOT_EMBEDDED);
> cb.setFontAndSize(bf,
> 11); // alltid vara 11 punkters times-new-roman
>
> ColumnText ct = new
> ColumnText( cb );
>
>
>
> ct.setSimpleColumn(position[1], position[4], position[3],
> position[2]);
> Element el = null;
>
> for (int idx = 0; idx
> < array.size(); idx++)
> {
> el =
> (Element)array.get(idx);
>
> ct.addElement( el );
> }
>
> // read-only
> af.setFieldProperty(
> bodyFieldName ,"setfflags", PdfFormField.FF_READ_ONLY, null);
>
> ct.go();
>
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&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions