0

I have certain requirement which is to print the 200 characters by picking the value from DB on to a PDF.

The text in the field can be of 0-200 characters. What ever the value which i have i the field i need display that in the PDF. I am using an xsl to format the text and printing the value in the PDF.

The issue over here is when the 200 characters are having some spaces the text is being displayed properly in the PDF. But when i enter a text without any spaces the text is being trimmed. i tried to increase the width of the PDF document but for normal text with spaces there is a lot space being empty and it is not looking good.

enter image description here

In the above image some text is being trimmed.

The below image shows the text with proper spaces.

enter image description here

How can i format the text properly using xsl irrespective of the text length with or without spaces. The text has to be adjusted accordingly to the page width of the PDF.

<fo:table table-layout="fixed">
                        <fo:table-column column-width="277mm" column-number="1"/>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell column-number="1">
                                    <fo:block font-size="18pt" font-weight="bold" text-align="left" line-height="23pt">
                                        <xsl:value-of select="//void[@property='additionalDescription']/string/text()"/>
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>

The PDF attributes

<fo:simple-page-master master-name="StandardPage" page-height="210mm" page-width="297mm">
                <fo:region-body margin-bottom="20mm" margin-top="12mm" margin-left="14mm" margin-right="6mm"/>
                <fo:region-before region-name="headerContent" extent="12mm"/>
                <fo:region-after region-name="footer" extent="20mm" precedence="true"/>
                <fo:region-start region-name="leftBorder" extent="14mm"/>
                <fo:region-end region-name="rightBorder" extent="6mm"/>
            </fo:simple-page-master>

Increasing the width of the PDF is making PDF look weird by leaving much space as empty towards right hand side.

Can you please let me know how this can be handled in xsl?

thanks Harsha GNS

Harsha GNS
  • 91
  • 1
  • 2
  • 11
  • Unfortunately I do not know how to handle this via xsl. But theoretically it is this: You are dealing with line break. It will be done automatically for you if you have whitespaces. But not if the text is "one word". So if you do not want to make the pdf look weird and keep a certain width, you'll have to check if the "box" of the text will exceed your document boundaries (graphically). If so, you'll have to introduce linebreaks manually. But as I said - no idea how to do this with only xsl. Does fo:block maybe have a switch to turn on "force line break"? – Fildor Jun 16 '16 at 07:55
  • 1
    There is "wrap-option" but it is active by default and does work as seen. Maybe these help: http://stackoverflow.com/q/17317588/982149 and http://stackoverflow.com/a/4533760/982149 – Fildor Jun 16 '16 at 08:41
  • 2
    See: - http://stackoverflow.com/questions/37162083/xsl-fo-wrapping-long-words-in-table-cell/37163951#37163951 - http://stackoverflow.com/questions/36810691/force-line-break-after-string-length/36887842#36887842 - http://stackoverflow.com/questions/4350788/xsl-fo-force-wrap-on-table-entries/33689540#33689540 – Tony Graham Jun 16 '16 at 09:26

0 Answers0