I'm at a loss trying to understand this. I'm new to using xsl-fo (apache-fop implementation) and I want a block with a border and the content inside padded so it's not bumped up against the border.
However when I add the padding, the padding is also applied to the following block?
<fo:page-sequence master-reference="report-page">
<fo:flow flow-name="xsl-region-body">
<fo:block border="1px solid black" font-size="8pt" margin-bottom="3mm" padding="3mm" >
<fo:block font-weight="bold">FOO</fo:block>
<fo:block>ANOTHER BLOCK</fo:block>
</fo:block>
<fo:block font-size="8pt">BAR</fo:block>
</fo:flow>
Why does BAR become indented by the amount of padding from the previous block? If I remove the padding on the first block, things line up fine?
What you should be doing is setting margin to "0mm" and padding to "3mm" on the block if your intention is to have no space outside the border and a 3mm space between the text and the border.
<fo:block border="1px solid black" font-size="8pt" margin="0mm" padding="3mm">
<fo:block font-weight="bold">FOO</fo:block>
</fo:block>
If the margin-bottom was intended to make space between elements, then you would use space-after or space-before on the following element.
Try to do the following (this is not tested because my Apache FOP installation is not within reach...)
EDIT : Now tested. Padding is only applied to the first block ("FOO").
Specify the padding inside a fo:inline element like this:
<fo:block border="1px solid black" margin-bottom="3mm">
<fo:inline padding="3mm" font-size="8pt" font-weight="bold">
<fo:block>FOO</fo:block>
</fo:inline>
</fo:block>
Also, I've moved the font-weight and font-size properties to the inline element, since the inner block is the only place they are needed (at least in your simple snippet). The outer block only defines the border. Let me know if this works.
Related
I created a block in a block-container. And inside the block, there will be few number of external-graphic dynamically. I expected the width of the images should not exceed the block-container width.
<fo:block-container width="90mm" display-align="center" text-align="center" margin-bottom="1mm">
<fo:block line-height="0mm">
<fo:external-graphic src="..."
content-width="scale-down-to-fit" content-height="scale-down-to-fit"
display-align="center" text-align="center"/>
<fo:external-graphic src="..."
content-width="scale-down-to-fit" content-height="scale-down-to-fit"
display-align="center" text-align="center"/>
</fo:block>
</fo:block-container>
I would have said to add content-width="scale-down-to-fit", but you already have that.
You might try removing the content-height property, since the height of the fo:block-container is not fixed.
You could also try removing both content-width and content-height and adding max-width="100%" (see https://www.w3.org/TR/xsl11/#max-width).
In my case, the trick was to combine content-height="scale-to-fit" and max-width="100%". When i removed one of them (whatever which of them), the image exceeded.
<fo:external-graphic src="..." content-height="scale-to-fit" max-width="100%" />
I am trying to add images in multiple rows.
Here is my code:
<fo:block-container reference-orientation="90" >
<xsl:for-each select="Icons/Icon">
<fo:block>
<fo:external-graphic src="{#Source}"/>
</fo:block>
</xsl:for-each>
</fo:block-container>
The <fo:block-container> is placed in an <fo:table-cell>.
You can see examples below where text is other part of the table.
How it looks:
But it should look like this:
I tried to add width for block-container, but it doesn't help.
It can't wrap because you're using a rotated fo:block-container, so what you're seeing is the rotated equivalent of blocks overflowing past the bottom of the page.
It's not clear to me why you're rotating the images, but you could put each graphic inside a separate fo:inline-container and set the reference-orientation on each. (See https://www.w3.org/TR/xsl11/#fo_inline-container)
<fo:table-cell>
<fo:block>
<fo:inline-container reference-orientation="90">
<fo:block>
<fo:external-graphic src="..." />
</fo:block>
</fo:inline-container>
...
</fo:block>
</fo:table-cell>
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
XSL-FO Overflow Handling for fo:inline-container Elements
My question is: How is it possible to break contents (e.g. fo:block elements) inside a fo:inline-container to a new page if the iherit contents are too long for the current one?
Used Fomatters: AHF 6.2, Apache FOP 2.1
The transformation has to work for both formatters; so a simple solution with fo:float elements is not possible.
Here is a short code extract:
<xsl:template match="myElement">
<fo:block>
<fo:inline-container inline-progression-dimension="33.333%">
<fo:block>
Marginalia Headline
</fo:block>
</fo:inline-container>
<fo:inline-container inline-progression-dimension="66.666%">
<fo:block>
Imagine this is a very long text ...
</fo:block>
<fo:block>
Imagine this is a very long text ...
</fo:block>
<fo:block>
Imagine this is a very long text ...
</fo:block>
<!-- MANY MORE fo:blocks -->
</fo:inline-container>
</fo:block>
</xsl:template>
The thing is, the contents are overflowing the fo:inline-container but are not breaking onto a new page. I think this has something to do with the surrounding fo:block element that keeps everything on a single page.
Any advice would be helpful here. Thank you in advance!
What works
Using fo:list-block
(Ok, you said you'd rather not use this trick ... anyway this works and could be used as a last resort)
You can put the marginalia in the fo:list-item-label and the "normal" text in the fo:list-item-body:
<fo:list-block provisional-distance-between-starts="33.333%">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
Marginalia Headline
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
Lorem ipsum dolor ...
</fo:block>
<!-- other blocks ... -->
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
Using overflowing fo:block-container
Alternatively, you could use a flatter sequence of formatting objects, putting the marginalia into a zero-height block container, so that the following block of normal text will start at the same height:
<fo:block-container height="0pt" overflow="visible" keep-with-next.within-page="always">
<fo:block end-indent="66.666%">
Marginalia Headline
</fo:block>
</fo:block-container>
<fo:block start-indent="33.333%">
Lorem ipsum dolor ...
</fo:block>
<!-- other blocks ... -->
Note that this solution can lead to a marginalia overflowing into the page bottom margin or overlapping the next marginalia if it produces more than X lines, where X is the orphans property of its corresponding normal text (for example, marginalia is three lines long while the normal text has orphans="2").
What does not work
Using fo:float
Even if FOP supports side-floats, I don't think using them would achieve the desired output, as the text would flow around it, returning to use all the available horizontal space as soon as possible:
<fo:block>
<fo:float float="left">
<fo:block width="33.333%" background-color="#AAFFFF">Marginalia Headline</fo:block>
</fo:float>
<fo:block background-color="#FFAAFF">
Lorem ipsum dolor ...
</fo:block>
<!-- other blocks ... -->
</fo:block>
Using fo:inline-container
I think the code in the question does not work as expected not because of something missing in the outer fo:block, but because of something missing in the fo:inline-container containing the long text: the overflow attribute.
If unspecified, its default value is "auto" which means the formatting object processor can do as it likes (probably showing the content even if overflows). With overflow="repeat" the processor should, if needed, create other areas, so that the content will be split into pages:
<fo:block>
<fo:inline-container inline-progression-dimension="33.333%">
<fo:block>
Marginalia Headline
</fo:block>
</fo:inline-container><fo:inline-container inline-progression-dimension="66.666%" overflow="repeat">
<fo:block>
Lorem ipsum dolor ...
</fo:block>
<!-- other blocks ... -->
</fo:inline-container>
</fo:block>
FOP, however, does not support overflow="repeat" (I cannot test with Antenna House XslFormatter, but the conformance page says it is supported).
(Disclosure: I am an inactive FOP developer)
Lets say I want to print a page number "01" as two separate digits 0 and 1 from 1 to 9
0X-> 01,02,03....
from 10 to 99
10,11,12
<fo:table-cell xsl:use-attribute-sets="TableCellBorder">
<fo:block>
<xsl:value-of select="substring(<fo:page-number/>, 1, 1)"/> //0 or first page-number digit
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="TableCellBorder">
<fo:block>
<xsl:value-of select="substring(<fo:page-number/>, 2, 1)"/>//second page-number digit
</fo:block>
</fo:table-cell>
any ideas how to do this?
<fo:page-sequence master-reference="mymaster" format="01">
...
<fo:page-number/>
...
</fo:page-sequence>
Described here, the only trick is figuring out where to place it.
Sorry, tested with XEP only; no idea if FOP supports it.
UPD. Would you consider adding the words of "leading zeros" in order to make the article searchable better?
This is not possible.
<fo:page-number/> is a XSL-FO construct. It does not get a value until the XSL-FO processor runs. It cannot be manipulated in the XSLT stylesheet that generates the XSL-FO markup.