So much work... Use ColumnText.showTextAligned(). It uses a Phrase that is composed of Chunk that can have any styles, fonts or color.
Paulo On Wed, Sep 12, 2012 at 3:07 PM, pgandhi <[email protected]> wrote: > Hi, > I'm trying to create a overlay text as shown in figure.Difficult part is i > had implemented it by PDFContentByte object showText() method.By Following > Code snippet: > > if(this.txtHdr!=null&& !"".equalsIgnoreCase(this.txtHdr.trim())){ > this.strtIndx = this.txtHdr.indexOf("*"); > this.lstIndx = this.txtHdr.lastIndexOf("*"); > > Font_Normal = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, > BaseFont.NOT_EMBEDDED); > Font_Bold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, > BaseFont.NOT_EMBEDDED); > > float textBrkFrst = > Font_Normal.getWidthPoint(this.txtHdr.substring(0,strtIndx),fontSz); > float textBrkScnd = > Font_Bold.getWidthPoint(this.txtHdr.substring(strtIndx+3,lstIndx),fontSz); > float textBrkThrd = > Font_Normal.getWidthPoint(this.txtHdr.substring(lstIndx+4),fontSz); > background.saveState(); > PdfTemplate tmpFrst = background.createTemplate(textBrkFrst,txtHght); > tmpFrst.beginText(); > tmpFrst.setFontAndSize(Font_Normal, fontSz); > tmpFrst.setTextMatrix(varVarx, varVary); > tmpFrst.showText(this.txtHdr.substring(0,strtIndx)); > tmpFrst.endText(); > background.add(tmpFrst); > background.restoreState(); > varVarx+=textBrkFrst;\\Due To Change StartPositon of The template > background.saveState(); > PdfTemplate tmpScnd = background.createTemplate(textBrkScnd,txtHght); > tmpScnd.beginText(); > tmpScnd.setFontAndSize(Font_Bold, fontSz); > tmpScnd.setTextMatrix(varVarx, varVary); > tmpFrst.showText(this.txtHdr.substring(strtIndx+3,lstIndx)); > tmpScnd.endText(); > background.add(tmpScnd); > background.restoreState(); > varVarx+=textBrkScnd; > background.saveState(); > PdfTemplate tmpThrd = background.createTemplate(textBrkThrd,txtHght); > tmpThrd.beginText(); > tmpThrd.setFontAndSize(Font_Normal, fontSz); > tmpThrd.setTextMatrix(varVarx, varVary); > tmpThrd.showText(this.txtHdr.substring(lstIndx+4)); > tmpThrd.endText(); > background.add(tmpThrd); > background.restoreState(); > } > Problem Is Bold Font Part is not displayed.I didn't get it.is something > wrong in this code.please advice.for any clarification you are welcome. > http://itext-general.2136553.n4.nabble.com/file/n4656292/ToBeCreated.jpg > > > > -- > View this message in context: > http://itext-general.2136553.n4.nabble.com/Creating-NormalAndBoldFont-Text-Combined-Using-PdfContentByte-showText-tp4656292.html > Sent from the iText - General mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > 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 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ 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
