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();
-------------------------------------------------------------------------
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

Reply via email to