Menu

image beside text using float with apache FOP 2

2016-08-26
2016-08-31
  • Stefan Quandt

    Stefan Quandt - 2016-08-26

    Hi,
    Apache FOP since release 2.0 has support for fo:float.
    Hence placing text beside an image should be possible using

    <figure float="1">
    

    and

    <figure floatstyle="left">
    

    according to http://www.sagehill.net/docbookxsl/FigureFloats.html.
    Though, using the former gives an error

     error: attribute "float" not allowed here; ...
    

    when compiling with daps-2.2.

    Using the latter (with docbook 5 sources) gives mixed results, depending on the output format:
    - With PDF output using floatstyle has just no effect
    - With HTML output using floatstylein fact renders text beside an image but without any spacing.
    Is the spacing somehow configurable?
    Also if the text contains an itemizedlist then the bullets will overlap with the image left to it (a workaround is to use <figure floatstyle="right">.

    Regards
    Stefan

     
  • Stefan Knorr

    Stefan Knorr - 2016-08-30

    Hi Stefan,

    I can tell you that DAPS does not do any external validation of generated FO files. So, the error message you have there really must come from FOP itself.

    FO situation: Unfortunately, I can't help you much more than that. I have never used floats in FO (at least not that I remember).

    HTML situation: I think you should be able to set a margin-left/margin-right using CSS on either your figure or your text to get some spacing. Having never worked with this, though, I can't really say how it's implemented. (I vaguely remember throwing out a lot of code in our customization layer that put images into tables, though. If there are tables in the output, this might become a bit more complicated.)

     
  • Stefan Quandt

    Stefan Quandt - 2016-08-31

    Hi Stefan,
    thanks for your response!

    So, the error message you have there really must come from FOP itself.

    No, it comes from the daps validation step (which employs xerces according to the log):

    Java virtual machine used: /usr/lib64/jvm/jre/bin/java
    classpath used: /usr/share/java/jing.jar:/usr/share/java/xerces-j2.jar:/usr/share/java/xml-commons-apis.jar:/usr/share/java/saxon6.jar:/usr/share/java/xml-commons-resolver.jar
    main class used: com.thaiopensource.relaxng.util.Driver
    flags used: '-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration'
    options used: '-Xss3072K'
    arguments used: -i /usr/share/xml/docbook/schema/rng/5.1/docbookxi.rng /home/stefan/devel/handbuch/build/.profiled/noprofile_remarks/settings.xml
      /usr/share/daps/make/html.mk:187  File `html' does not exist.
    /home/stefan/devel/handbuch/build/.profiled/noprofile_remarks/settings.xml:18:49: error: attribute "float" not allowed here; expected attribute "annotations", "arch", "audience", "condition", "conformance", "dir", "floatstyle", "label", "linkend", "ns:actuate", "ns:arcrole", "ns:from", "ns:href", "ns:label", "ns:role", "ns:show", "ns:title", "ns:to", "ns:type", "os", "outputformat", "pgwide", "prefix", "property", "remap", "resource", "revision", "revisionflag", "role", "security", "typeof", "userlevel", "vendor", "version", "vocab", "wordsize", "xml:base", "xml:id", "xml:lang" or "xreflabel" (with xmlns:ns="http://www.w3.org/1999/xlink")
    

    The docbook schema used seems to be incomplete:
    While the use of attribute float in <figure> is rejected, attribute floatstyle is accepted.
    But this is not a crucial issue, since the floatstyle attribute may be used alternatively and is also more specific.

    Regarding the spacing of text beside a float figure, I would expect that this could be achieved with a value for the widthattribute slightly bigger then contentwidthin the <imagedata> child element, like in

    <informalfigure floatstyle="left">
      <mediaobject>
          <imageobject>
            <imagedata fileref="my.png" width="60" contentwidth="50"/>
          </imageobject>
    

    Unfortunately in this case the width attribute has no effect on the spacing in rendered HTML output.

    On the other hand, when placing an <imageobject> inline in text, the width attribute works just fine, like in

    <para>This is an
      <inlinemediaobject>
        <imageobject>
          <imagedata fileref="icon.png" width="25" contentwidth="20" align="center" />
        </imageobject>
      </inlinemediaobject>
      icon.
    </para>
    
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.