I have created a pdf template with a table.
The table has a border; after rendering all the data, the content covers only half of the page, so the table border covers only the content.
But I want the table border to cover the entire page regardless of the height of the content, like this:
I have tried to set height of table to 100%, but no luck.
I have also tried to put block-progression-dimension.optimum="100%"
on last table cell; let me know if that's the right place
<fo:page-sequence master-reference="A4-portrait">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="14pt" margin-bottom="11pt" height="100%">
<fo:table border-width="1pt" border-style="solid" height="100%" border-color="grey" margin-top="-110pt" font-family="Gotham Narrow A, Gotham Narrow B, Helvetica, Arial, sans-serif">
<fo:table-body>
<fo:table-row>
<fo:table-cell number-columns-spanned="2" margin-left="20pt">
<fo:block text-align="left" font-weight="bold" font-size="13pt" color="black" margin-bottom="2pt" margin-top="15pt" margin-left="-5pt">
${ctx.messages.repairInstructionTitle}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairInstructionMessage1}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairInstructionMessage2}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairInstructionMessage3}
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:table margin-top="10pt" margin-bottom="15pt">
<fo:table-column column-width="50%"/>
<fo:table-column column-width="50%"/>
<fo:table-body>
<fo:table-row>
#if ($ctx.orderData.deliveryAddress.country.isocode == 'US')
<fo:table-cell margin-left="30pt" number-columns-spanned="1">
<fo:block text-align="left" font-weight="bold" font-size="9pt" color="black">
${ctx.messages.repairQuestionForLocationMainland}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.mauijimIncMainland}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairDepartmentLable}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairDepartmentMainlandAddressLine1}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairDepartmentMainlandAddressLine2}
</fo:block>
</fo:table-cell>
<fo:table-cell margin-left="20pt">
<fo:block text-align="left" font-weight="bold" font-size="9pt" color="black">
${ctx.messages.repairQuestionForLocationHawaii}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.mauijimIncHawaii}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairDepartmentLable}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairDepartmentHawaiiAddressLine1}
</fo:block>
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairDepartmentHawaiiAddressLine2}
</fo:block>
</fo:table-cell>
#end
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell margin-left="15pt" block-progression-dimension.optimum="100%">
<fo:block text-align="left" font-size="13pt" color="black" font-weight="bold">
${ctx.messages.repairAnyQuestionText}
</fo:block>
#if (${ctx.orderData.deliveryAddress.country.isocode} == 'US')
<fo:block text-align="left" font-size="9pt" color="black">
${ctx.messages.repairContactInfo}
</fo:block>
#end
#if (${ctx.orderData.deliveryAddress.country.isocode} != 'US')
<fo:block text-align="left" font-size="9pt" color="black">
#set($repairContactInfo = "repairContactInfo")
#set($isocode = $ctx.orderData.deliveryAddress.country.isocode )
#set($addMessage = "$repairContactInfo$isocode")
${ctx.messages.getMessage($addMessage)}
</fo:block>
#end
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
I am not sure what effect you are trying to achieve. The height="100%" on the fo:table makes it 100% of the height of its containing block, but the fo:block has margin-bottom="11pt", which reduces the height available for the fo:block and, therefore, for the fo:table.
The height="100%" gives the table a fixed height, but the margin-top="-110pt" shifts the table up by 110pt so that I'm currently seeing 110pt of blank space after the table.
If you want something really is 100% of the page height, use height="100pvh". See https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#pvh
(Also, margin-left does not apply to fo:table-cell.)
From the image of the expected output, it looks like you want to have a border around the main page region, regardless of the actual height of its content.
So, it may be enough to move the definition of the border in the fo:region-body element and remove it from the fo:table; you may also consider removing the table altogether and leaving only the blocks it contains, as it does not seem to have any function other than drawing the border.
A couple of points worth mentioning:
strictly speaking, this would not be allowed by the XSL-FO Recommendation ("The values of the padding and border-width traits must be "0"."), but is generally allowed by the formatters (AntennaHouse Formatter allows it);
this solution is easy to implement if all pages must have a border around the main region; otherwise, you have to modify your templates so that a page sequence with a bordered region-body is created for the content that needs it, and different page sequences using a page master with not borders are created for the rest of the content.
Related
I am using an xml data similar to the sample below. There is a list of possible risks, and each of them can have a name and a description.
<risks>
<freezeDeductible name="item1" description="desc 1"/>
<moneySecLimit name="item2" description="desc 2"/>
<unscheduledLimit name="item3" description="desc 3"/>
...
</risks>
The structure of my template looks as below:
<xsl:template name="displayRisks">
<fo:block>
<fo:table>
<fo:table-column column-width="proportional-column-width(33.333)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(33.333)" column-number="2"/>
<fo:table-column column-width="proportional-column-width(33.333)" column-number="3"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block font-weight="bold">ALL RISKS</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/freezeDeductible/#name"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/freezeDeductible/#description"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block> </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/moneySecLimit/#name"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="/risks/moneySecLimit/#description"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
From the above template, I am generating PDF outputs. Because of the risk description size, and the number of risks elements is unknown, the table can go over multiple one or pages.
On the column1 x row1, there is displayed on first page, the title - "ALL RISKS". It needs to be on the same line as first risk name and description, so cannot move it to the table-header.
Is there any way that, when the table gets to page2, page3, etc. , to display the title (ALL RISKS) on the first row of the new page, with a label - for example: (continue..) ?
For example:
Page1: should display the title, on first table-row, as follows: ALL RISKS
If there is a Page2: display the title on the first table-row on Pag2, as follows: ALL RISKS(continued..)
Thanks!
There is an fo:retrieve-table-marker example in the 'XSL-FO Samples Collection' at https://www.antennahouse.com/xsl-fo-samples#table-retrieve-table-marker-1. (You may need to scroll up after you follow the link because of the banner on the page.)
There's also an example of the axf:repeat-content-at-break and axf:table-cell-repeated-marker AH Formatter extensions at https://www.antennahouse.com/xsl-fo-samples#axf-table-cell-repeated-marker-1 that demonstrates both the repetition and a '(Continued)' marker like what you want.
I'm using XSLT to output a document in PDF.
On the page header I need to add a jpeg company logo, does anybody know how to do this:
below is my page header format:
<fo:static-content flow-name="xsl-region-before">
<fo:block font-family = "Courier" font-size =>
<fo:table>
<fo:table-column column-width = "15mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:static-content>
I'm new to XSLT so I'd appreciate some help :-)
I'm trying to align an inline container horizontally, but I can't find the corresponding FO attribute like display-align for vertical alignment.
Here is some example code without any alignment:
<fo:inline-container background-color="white" border-style="solid" border-width="2mm" border-color="white">
<fo:block font-family="Blablabla" text-align="center" font-size="54pt" space-after="6mm" text-indent="0mm" last-line-end-indent="0mm" alignment-baseline="central">
...
</fo:block>
</fo:inline-container>
The whole thing is going to be processed with AntennaHouse 5.2.
Thanks in advance
Stavros
Add text-align="center" to the fo:block (or similar) that contains the fo:inline-container:
<fo:block text-align="center">
<fo:inline-container background-color="white" border-style="solid" border-width="2mm" border-color="white">
<fo:block font-family="Blablabla" text-align="center" font-size="54pt" space-after="6mm" text-indent="0mm" last-line-end-indent="0mm">
...
</fo:block>
</fo:inline-container>
</fo:block>
Also, your alignment-baseline="central" doesn't do anything since alignment-baseline doesn't apply to fo:block and is not inherited. See https://www.w3.org/TR/xsl11/#alignment-baseline
I am using below line to achive dynamic row height i.e the height should match with the left column .
But I also need to split the row into different cells ? When I am using simple fo:block-cell attrbutes ,I am not getting dynamic row hight . How can achive both dynamic row hieght and cells ??
<fo:table-row display-align="center">
<xsl:for-each select="xalan:distinct(Number)">
<fo:table-cell block-progression-dimension="auto" >
<fo:block-container height="10mm">
<fo:block font-size="9pt" border-right-width="0.1mm" border-right-style="solid" border-right-color="red" >
<xsl:value-of select="">
<xsl:variable name="">
<xsl:value-of select="">
</xsl:variable>
<xsl:if test="">
<xsl:value-of select=""/>
</xsl:if>
</fo:block>
</fo:block-container>
</fo:table-cell>
snapshot
Update -
I think one way that it could be done is to insert a vertical line after every cell value .Tried this , but somehow vertical line is not printing .
<fo:table-cell number-columns-spanned="2" xsl:use-attribute-sets="myBorder" display-align="center">
<fo:block font-size="10pt" text-align="center">
<fo:table>
<fo:table-body>
<fo:table-row>
<xsl:for-each select="../../../rateDetails[toGeography/sequence = $currentSequence]">
<fo:table-cell><!-- block-progression-dimension="auto" border-right-width="0.1mm" border-right-style="solid" border-right-color="black" text-align="center"> -->
<fo:block-container>
<fo:block font-size="9pt"><!-- border-right-width="0.1mm" border-right-style="solid" border-right-color="black" text-align="center"> -->
<xsl:call-template name="currencySymbol">
<xsl:with-param name="currencyCode" select="$currencyCode" />
</xsl:call-template>
<xsl:value-of select="util:formatCurrency(rate,$language,$countryCode)" />
</fo:block>
</fo:block-container>
<fo:block-container reference-orientation="90">
<fo:block>
<fo:leader leader-pattern="rule" leader-length="100%" rule-style="solid" rule-thickness="0.1mm" color="black"/>
</fo:block>
</fo:block-container>
</fo:table-cell>
</xsl:for-each>
Is there anything that I am missing for vertical line insertion .
snapshot2
If you move the border and padding properties to the fo:table-cell, the border will be the full height of the cell:
<fo:table-cell border-right="0.1mm solid red">
By setting fo:block-container/#height, you're probably finding that the text in a cell can overflow the 10mm but only the 10mm is being used to determine the row height. If you remove the fo:block-container, you should get a variable-height table row.
The new code sample makes things a bit clearer: you're using 2 nested tables.
That's another complication you don't need.
Just use 1 table.
In the first column, place all the geography codes into the first cell. It does not matter how many there are: if you have 1 geography code, the cell will be one line high. If you have 16 geography codes in this cell, the cell will automatically resize to be 3 lines high.
The rest of the row contains cells with the price information. On these cells, define the right border to generate the red vertical line.
<fo:table>
<fo:table-column column-width="..mm" column-number="1"/>
<fo:table-column column-width="..mm" column-number="2"/>
...you'll have to add some code here to add the correct number of columns to your table...
<fo:table-body>
<fo:table-row>
<fo:table-cell>
...place the code to insert the country codes here....
</fo:table-cell>
<xsl:for-each select="../../../rateDetails[toGeography/sequence = $currentSequence]">
<fo:table-cell block-progression-dimension="auto" border-right-width="0.1mm" border-right-style="solid" border-right-color="black" text-align="center">
<fo:block-container>
<fo:block font-size="9pt">
<xsl:call-template name="currencySymbol">
<xsl:with-param name="currencyCode" select="$currencyCode" />
</xsl:call-template>
<xsl:value-of select="util:formatCurrency(rate,$language,$countryCode)" />
</fo:block>
</fo:block-container>
</fo:table-cell>
</xsl:for-each>
I am trying to split a particular column with a simple horizontal line .
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell border-color="white" padding-top="5px" padding-bottom="5px">
<fo:block>
<xsl:choose>
<xsl:when test=>
<fo:block border-bottom-width="0.1mm" border-bottom-style="solid" border-bottom-color="black" font-weight="bold">
First I tried to make another table in a column for splitting of data but its not working. border-bottom inside <fo:block > is also not helping .
The line doesn't seem to properly split the column .How can I do this .
On my comment above, the best solution is change your logic to apply appropriate spanning. Here is some FO to get you thinking:
<fo:table font-size="18pt">
<fo:table-body>
<fo:table-row>
<fo:table-cell number-rows-spanned="2" border="1pt solid black" padding="3pt">
<fo:block>I am all in one spanned cell</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="3pt">
<fo:block>I am in top half of the cell</fo:block>
</fo:table-cell>
<fo:table-cell number-rows-spanned="2" border="1pt solid black" padding="3pt">
<fo:block>I am all in one spanned cell</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="3pt">
<fo:block>I am in bottom half of the cell</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
The result is: