Apache FOP2 is adding unwanted spacing between images

时间秒杀一切 提交于 2019-12-11 23:02:11

问题


I'm trying to take a sliced up A4 design (designed in photoshop) and re-creating it in Apache FOP.

Here's a snippet of a section that's in the design:

and this is what it looks like when I take the images and place them in the XML:

The big white gaps below referenceegoeshere and amountgoeshere is caused by the last image overflowing. When I remove it, I still get spacing around images:

The design is done in 300dpi and the sliced up images are still 300dpi.

In Apache FOP's config I've set the DPI to 300 as well.

<fop version="1.0">

        <strict-configuration>true</strict-configuration>
        <strict-validation>true</strict-validation>
        <base>./</base>
        <font-base>./</font-base>

        <source-resolution>300</source-resolution>
        <target-resolution>300</target-resolution>

</fop>

This is my full FOP template (the images doesn't exist at that location, I've renamed them to protect the client's identity)

<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master
                margin="0mm"
                padding="0mm"
                master-name="simple"
                page-height="297mm"
                page-width="210mm">
            <fo:region-body margin="0" />
            <fo:region-before extent="0"/>
            <fo:region-after extent="0"/>
        </fo:simple-page-master>
    </fo:layout-master-set>

    <fo:page-sequence master-reference="simple" color="#365f91">

        <!-- Page Body Goes Here -->
        <fo:flow flow-name="xsl-region-body">
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_01.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_02.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_03.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_04.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_05.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_06.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_07.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_08.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_09.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_10.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_11.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_12.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_13.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_14.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_15.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_16.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_17.jpg"/>
             </fo:block>
             <fo:block padding="0mm" margin="0mm">
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_18.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_19.jpg"/>
                 <fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_20.jpg"/>
             </fo:block>


        </fo:flow>

    </fo:page-sequence>
</fo:root>

I've added some background colour to demostrate the spacing between images, it's almost like there's a transparent border around images when there should be no spacing at all.

How do I get rid of the spacing being added around images?


回答1:


Finally figured it out, adding font-size="0" on each of the blocks strips out the spacing around images.

Very strange, but it works.



来源:https://stackoverflow.com/questions/33891914/apache-fop2-is-adding-unwanted-spacing-between-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!