Re: issues with page margins and background images
Hussein Shafie <[email protected]> Sat, 8 Apr 2017 11:56:28 +0200
| Newsgroups | gmane.text.xml.xfc.general |
|---|---|
| Message-ID | <[email protected]> |
Enoch K. wrote:
> I have run into some issues regarding XMLMind when converting the XML:FO to DocX/RTF format through XMLMind, and I am hoping that there is a solution to remedy these issues. Since, this is an escalated issue in which one of our customers have brought up to us. We’d like to get this resolved as soon as possible. Below is the section of the XML:FO that we are sending into XMLMind for conversion:
>
>
>
> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
>
> <fo:layout-master-set>
>
> <fo:simple-page-master master-name="AAA" page-height="11.0in" page-width="8.5in" margin-top="0in" margin-bottom="0in">
>
> <fo:region-body background-image="background_image.png" margin-bottom="1.0in" margin-right="1in" margin-left="1in" overflow="hidden" background-position-horizontal="center" background-position-vertical="center" background-repeat="no-repeat" column-gap="0.25in" column-count="1"/>
>
> <fo:region-before/>
>
> <fo:region-after/>
>
> <fo:region-start/>
>
> <fo:region-end/>
>
> </fo:simple-page-master>
>
> <fo:simple-page-master master-name="BBB" page-height="11.0in" page-width="8.5in" margin-top="0in" margin-bottom="0in">
>
> <fo:region-body background-image="some_dummy_image.png" margin-bottom="1.0in" margin-top="1.0in" margin-right="1in" margin-left="1in" overflow="hidden" background-position-horizontal="center" background-position-vertical="center" background-repeat="no-repeat" column-gap="0.25in" column-count="1"/>
>
> <fo:region-before/>
>
> <fo:region-after/>
>
> <fo:region-start/>
>
> <fo:region-end/>
>
> </fo:simple-page-master>
>
> <fo:simple-page-master master-name="CCC" page-height="11.0in" page-width="8.5in" margin-top="0in" margin-bottom="0in">
>
> <fo:region-body background-image="some_dummy_image.png" margin-bottom="1.0in" margin-right="1in" margin-left="1in" overflow="hidden" background-position-horizontal="center" background-position-vertical="center" background-repeat="no-repeat" column-gap="0.25in" column-count="1"/>
>
> <fo:region-before/>
>
> <fo:region-after/>
>
> <fo:region-start/>
>
> <fo:region-end/>
>
> </fo:simple-page-master>
> </fo:layout-master-set>
>
> <fo:bookmark-tree/>
>
> <fo:page-sequence text-decoration="none" font-style="normal" font-weight="normal" line-height="100%" text-align="left" color="#000000" font-size="12pt" font-family="Helvetica" master-reference="AAA">
>
> <fo:flow flow-name="xsl-region-body">
>
> <fo:block-container overflow="hidden">
>
> <fo:block margin-right="0in" margin-left="0in" margin-bottom="0in" margin-top="0in">
>
> <fo:block text-align="left" line-height="12pt">test text 1</fo:block>
>
> </fo:block>
>
> </fo:block-container>
>
> </fo:flow>
>
> </fo:page-sequence>
>
> <fo:page-sequence text-decoration="none" font-style="normal" font-weight="normal" line-height="100%" text-align="left" color="#000000" font-size="12pt" font-family="Helvetica" master-reference="BBB">
>
> <fo:flow flow-name="xsl-region-body">
>
> <fo:block-container overflow="hidden">
>
> <fo:block margin-right="0in" margin-left="0in" margin-bottom="0in" margin-top="0in">
>
> <fo:block text-align="left" line-height="12pt">
>
> <fo:inline font-family="Helvetica" font-size="12pt" color="#000000">test text 2</fo:inline>
>
> </fo:block>
>
> </fo:block>
>
> </fo:block-container>
>
> </fo:flow>
>
> </fo:page-sequence>
>
> <fo:page-sequence text-decoration="none" font-style="normal" font-weight="normal" line-height="100%" text-align="left" color="#000000" font-size="12pt" font-family="Helvetica" master-reference="CCC">
>
> <fo:flow flow-name="xsl-region-body">
>
> <fo:block-container overflow="hidden">
>
> <fo:block margin-right="0in" margin-left="0in" margin-bottom="0in" margin-top="0in">
>
> <fo:block text-align="left" line-height="12pt">
>
> <fo:inline font-family="Helvetica" font-size="12pt" color="#000000">test text 3</fo:inline>
>
> </fo:block>
>
> </fo:block>
>
> </fo:block-container>
>
> <fo:block id="lastBlockId" font-family="Helvetica" line-height="0pt" font-size="1pt"> </fo:block>
>
> </fo:flow>
>
> </fo:page-sequence>
>
> </fo:root>
>
>
>
> As you see there are three separate simple-page-master that we are using to create three separate pages with different properties (header-margin & background images). Only the 1st simple-page-master has an actual background image, and only the 2nd simple-page-master has a header margin of 1 inches when other two pages have 0 inches. One thing to note is that we have added the “some_dummy_image.png”, which is a 1x1 pixel image, to prevent the first background image from repeating in subsequent pages since “none” option causes this issue. The result in the PDF output works as how we have set up, but when we preview this document in DocX or RTF, we are seeing the header margin for both.
>
>
>
> The peculiar thing is that when you look at the page layouts for each page, you see that the top margin is 0 inches for 1st and 3rd pages and 1 inch for 2nd page. Yet, 1st and 3rd pages contain header margin as well. After further investigation, when you unzip the docx file, you see three separate xml files for header1, header2, and header3 referring to headers for pages 1, 2, and 3, respectively. In these header files, the ‘imagedata’ is being referred to rather than in the document.xml file, which I’m assuming where the ‘imagedata’ should be located since, we have defined the background image in the ‘simple-page-master’, specifically in the ‘region-body’. Therefore, my base question is why or what happens to the XMLMind that converts this XSL:FO that outputs the background image in the header.xml rather than in the document.xml>. Moreover, is there any way that we could fix this issue or a workaround.
1) Why specify the background image in the header.xml rather than in the
document.xml?
ANSWER: because it's the only way to have different background images
(or no background image at all) on different sections of a document.
2) How to have a background image just on my first page sequence and not
on the other page sequences?
ANSWER:
* Use your 1x1 some_dummy_image.png trick.
OR
* Specify background-image="none" (or no background-image) and also
specify an empty header as follows:
---
<fo:simple-page-master master-name="BBB" ...
...
<fo:region-before extent="1.0in"/>
...
<fo:page-sequence text-decoration="none"
font-style="normal" font-weight="normal" line-height="100%"
text-align="left" color="#000000" font-size="12pt"
font-family="Helvetica" master-reference="BBB">
<fo:static-content flow-name="xsl-region-before">
<fo:block></fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
...
---
3) Why all my document sections have a 1in top margin?
ANSWER:
MS-Word wants a page to have a top margin anyway. That is, something like:
---
<fo:simple-page-master master-name="AAA"
page-height="11.0in" page-width="8.5in" margin-top="0in"
margin-bottom="0in">
---
cannot result in something which is honored by MS-Word.
The best you can do is specify a very small value for these margins.
---
<fo:simple-page-master master-name="AAA"
page-height="11.0in" page-width="8.5in" margin-top="0.001in"
margin-bottom="0.001in">
---
The result obtained this way is slightly better than before, but still
not perfect.
---> In conclusion, we don't think that you have uncovered bugs we could
fix. You seem to have faced very annoying limitations which are inherent
to the fact that the DOCX format is way less flexible, way less
"graphical", than the PDF format.
Please consider that when it comes to the above features (0-margin
pages, page background images), our product, XMLmind XSL-FO Converter,
implements just "a best effort".
Sorry for all these troubles.
--
XMLmind FO Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xfc-support