java - Text overlaping problem using itext for generating a pdf -
hi have header text(artist biography(continue)) in pdf file generated using itext(java).where 'artist' , '(continue)' static text 'biography' dynamic text varied respect content fetched xml.my problem while dynamic text length long overlap '(continue)' text.how can set dynamic text length respect nearest static text'(continue)'.please reply in advance
my code displaying header text (artist biography(continue)) written bellow
pdfcontentbyte cb = writer.getdirectcontent(); basefont bf = basefont.createfont(basefont.helvetica, basefont.cp1252, basefont.not_embedded); cb.setfontandsize(bf, 18); cb.begintext(); cb.setcolorfill(color.black); cb.showtextaligned(pdfcontentbyte.align_left,"artist", document.left(), document.top() + 20 , 0); cb.resetrgbcolorfill(); cb.endtext(); cb.begintext(); cb.setcolorfill(color.red); cb.showtextaligned(pdfcontentbyte.align_left, strbiography, document.left() + 70, document.top() + 20, 0); cb.resetrgbcolorfill(); cb.endtext(); cb.begintext(); cb.setcolorfill(color.black); cb.showtextaligned(pdfcontentbyte.align_left,"(continue)", document.left()+90, document.top() + 20 , 0); cb.resetrgbcolorfill(); cb.endtext(); cb.stroke();
you can create chunk right font , content of strbiography , on chunk call getwidthpoint it's size in points, you'll have length of strbiography when added doc , can calculate position of "(continue)"
Comments
Post a Comment