Subject: Re: [xsl] Calculating the size of a string From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 15 Aug 2012 08:15:37 -0400 |
I have an xml input that will be processed into a FO file, via Saxon and Apache's FOP (1.0). The resulting string will eventually be output to a fo:table-cell. FOP does a decent job of hyphenating, however it is not perfect. If I have a string input like this:
<pnr>PN-THIS.IS.A.LONG.PN12.23.56</pnr>
The output on PDF looks like this:
PN- THIS.IS.A.LONG.PN12.23.56
the problems is that my cell is very small. I would like to have it look like this:
PN-THIS.IS.A. LONG.PN12. 23.56
I found a workaround, where if I include spaces in the string, I get better results:
<pnr>PN-THIS.IS.A.LONG. PN12.23. 56</pnr>
However, this requires changing the input, which I don't want to do. I can not use string-length because the size of the space can vary depending on the characters used. For example, 'WWWWW', is bigger than 'iiiii' in actual size. Both return a string-length of 5, but are not the same size. So, I've written a java extension that will return the size of the Rectangle2D width. I have an idea of where the 'line' break should be (140 the width of the framing rectangle), but I am not sure how to translate the width into a function in xslt to add the spaces.
Any ideas?
http://www.CraneSoftwrights.com/training/#pfux (use the "Try and Buy free trial A4/US download" links)
-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Calculating the size of a str, Philip Vallone | Thread | Re: [xsl] Calculating the size of a, Philip Vallone |
[xsl] Calculating the size of a str, Philip Vallone | Date | Re: [xsl] Calculating the size of a, Philip Vallone |
Month |