Reputation: 231
I’m using XML2PDF to create badges for printing. Unfortunately I’m running into an issue where, when creating a new page (page-break-after=”always”), the next block-container is duplicated. This seems to happen when the block-container has a specified height. Without the height attribute the data looks okay (though I need to specify the heights).
I also noticed that increasing the page-height in simple-page-master also fixes this. I'm not sure why since the block-containers and margin don't go over the 11in height.
Any help is greatly appreciated. Please let me know if I'm missing any information
Note:
There are 6 badges per page. 2 columns and 3 rows. (each badge has a width of 4 inches and a height of 3 inches)
Each page has a footer that has a width of 4 inches and a height of 1.5 inches
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="badge" page-width="8.5in" page-height="11in" margin-top="0.00in" margin-bottom="0.00in" margin-left="0.00in" margin-right="0.00in">
<fo:region-body margin=".25in"/>
<fo:region-before extent="0in"/>
<fo:region-after extent="0in"/>
<fo:region-start extent="0in"/>
<fo:region-end extent="0in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="badge">
<fo:flow flow-name="xsl-region-body">
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 1</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 2</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float clear="left"/>
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 3</fo:block>
<fo:block font-size="18px">FullName</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 4</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float clear="left"/>
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 5</fo:block>
<fo:block font-size="18px">Full Name </fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 6</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px"/>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float clear="left"/>
<fo:block-container background-color="gray" height="1.5in" width="8in" page-break-after="always">
<fo:block> Text goes here </fo:block>
</fo:block-container>
<fo:float float="left">
<fo:block-container background-color="gray" height="3in" width="4in">
<fo:block font-size="34px" font-weight="bold">Name - 7</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
</fo:flow>
</fo:page-sequence>
Upvotes: 0
Views: 191
Reputation: 8877
I believe I understand your issue, are you saying that the block-container with "Text goes here" is thrown to the following page? While you "think" that the spacing all adds up, you are missing one thing in your mind. When you throw the fo:float, it has an inherent line height based on the default font. If you want this to fit perfectly, you need to set the line-height to "0" on the floats and then set it back to normal on the block-container inside. Your file as is is actually off by the line height of the first block. This formats to two pages (note I also removed the empty fo:float elements, that is technically an error to a formatter as a float cannot be empty and they are not needed).
(Tested with RenderX's formatter only, I do not have XML2PDF):
<fo:page-sequence master-reference="badge">
<fo:flow flow-name="xsl-region-body">
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 1</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 2</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 3</fo:block>
<fo:block font-size="18px">FullName</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 4</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 5</fo:block>
<fo:block font-size="18px">Full Name </fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 6</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px"/>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
<fo:block-container background-color="gray" height="1.3in" width="8in" page-break-after="always" clear="left">
<fo:block> Text goes here </fo:block>
</fo:block-container>
<fo:float float="left" line-height="0">
<fo:block-container background-color="gray" height="3in" width="4in" line-height="normal">
<fo:block font-size="34px" font-weight="bold">Name - 7</fo:block>
<fo:block font-size="18px">Full Name</fo:block>
<fo:block font-size="18px">Company</fo:block>
<fo:block font-size="18px">City, State</fo:block>
</fo:block-container>
</fo:float>
</fo:flow>
</fo:page-sequence>
Upvotes: 1