It can be done with this modifications. Best Regards, Paulo Soares
----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 15, 2002 20:03 Subject: [iText-questions] Set Character Spacing Question (follow up) > I figured out how the set char spacing call works . . . adds the value, > does not scale. When I changed the algorithm > on that basis it works quite well to approximate the metrics of the printer > font. It would be great to find a way > to hit the metrics on the head . . . does the notion of subclassing the > font object have merit? Still looking for > other suggestions. > > progress anyway. > > Thanks, > Jerry Sampson > > > ----- Forwarded by Jerry Sampson/ON/CheckFree on 02/15/02 12:59 PM ----- > |---------+----------------------------> > | | Jerry Sampson | > | | | > | | 02/15/02 12:59 PM| > | | | > |---------+----------------------------> > >--------------------------------------------------------------------------- ----------------------------------------------------| > | | > | To: [EMAIL PROTECTED] | > | cc: | > | Subject: Set Character Spacing Question(Document link: Jerry Sampson) | > >--------------------------------------------------------------------------- ----------------------------------------------------| > > > > Greetings. > > I am trying to create a text string in a content byte object which has a > specific length. Since iText does not support user supplied > font width tables I am trying to adjust the character spacing to compensate > for the difference in the measured length using the basefont and the > desired length. The desired length is based on a printstream font which > does not exist in the pdf environment. I tried the following code: > > // txt is an incoming text token that is being rendered in the PDF page > // c is the content byte object > > BaseFont font = > BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI,BaseFont.NOT_EMBEDDE D); > float fs = txt.ps/10f; // font pontsize > float x = getX(txt.x,txt.units); > float y = getY(txt.y,txt.units); > float l = getPoints(txt.l,txt.units); // desired length of string in > points > float r = 0; > if (txt.iDir != 0) > r = 360-txt.iDir; > float tw = font.getWidthPoint(text,fs); // width of string using the > basefont > c.setFontAndSize(font,fs); > c.setCharacterSpacing(l/tw); > c.beginText(); > c.showTextAligned(c.ALIGN_LEFT,text,x,y,r); > c.endText(); > > > The result is not what i hoped for . . . the resulting length of the token > in the PDF does not match the length in the printstream as I expected. > > Does anyone out there know how I can solve this problem? . . . I need to > get a PDF string length to match a specific > value. > > With the Adobe library it was easy because you could set the width table > for a font to match any font you like . . . however that > lib is C only and has its own set of problems. > Is there some way to accomplish this with iText . . . building zillions of > custom > fonts in a font library is not an option. Could I subclass a font object > and provide widths? . . . Would they end up in the PDF > as a width table object associated with the font? Other ideas? > > I am open to suggestions. > > Thanks in advance, > Jerold Sampson > > > > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions >
set_widths.zip
Description: Zip compressed data
