Having problems with Margins
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Mon May 17, 2010 12:42 pm
Having problems with Margins
I am trying to create a PDF from an XML file using FOP.
I have a background that needs to have zero margins so that it fits the page. The content has a margin. The margins that I have given for the content is being applied to the first page alone. From the second page onwards, the content is takign a top margin of ZERO. The Left and right margins are being applied properly.
Can anyone help me on this. I have been struggling with this for quite some time.
Below is the XSL code.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="reportstart">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="mypage" page-height="11in" page-width="8.5in" margin-top="0" margin-bottom="0" margin-left="0" margin-right="0">
<fo:region-body background-image="ppdf06d_72.png" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="mypage" >
<fo:flow flow-name="xsl-region-body" >
<fo:block font-size="7pt" font-family="Courier" font-weight="bold" font-style="normal" margin-top="0.5in" margin-bottom="0.2in" margin-left="0.3in" margin-right="0.3in">
<xsl:apply-templates select="report" />
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="report">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="dataline">
<fo:block linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="processing-instruction('hard-pagebreak')">
<fo:block break-after="page"/>
</xsl:template>
</xsl:stylesheet>
I have a background that needs to have zero margins so that it fits the page. The content has a margin. The margins that I have given for the content is being applied to the first page alone. From the second page onwards, the content is takign a top margin of ZERO. The Left and right margins are being applied properly.
Can anyone help me on this. I have been struggling with this for quite some time.
Below is the XSL code.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="reportstart">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="mypage" page-height="11in" page-width="8.5in" margin-top="0" margin-bottom="0" margin-left="0" margin-right="0">
<fo:region-body background-image="ppdf06d_72.png" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="mypage" >
<fo:flow flow-name="xsl-region-body" >
<fo:block font-size="7pt" font-family="Courier" font-weight="bold" font-style="normal" margin-top="0.5in" margin-bottom="0.2in" margin-left="0.3in" margin-right="0.3in">
<xsl:apply-templates select="report" />
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="report">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="dataline">
<fo:block linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="processing-instruction('hard-pagebreak')">
<fo:block break-after="page"/>
</xsl:template>
</xsl:stylesheet>
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Having problems with Margins
Post by sorin_ristache »
Hello,
That happened because you set the margins on a fo:flow. If you want the same margins on all pages you should set them on fo:region-body:
Regards,
Sorin
That happened because you set the margins on a fo:flow. If you want the same margins on all pages you should set them on fo:region-body:
Code: Select all
...
<fo:region-body background-image="ppdf06d_72.png" margin-top="0.5in" margin-bottom="0.2in" margin-left="0.3in" margin-right="0.3in"/>
...
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service