OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Fitting tall images in PDF


> Really this should be a feature of the stock xslts though.

Indeeed, Antenna House also supports it since version 6. Any suggestions about how to fit this feature into the XSL? Here are some requirements that I see:

1. It needs to support "scale-up-to-fit" values as well, and both values supported on either content-height or content-width.

2. I think we need to be able to specify it for an individual image as well as for the global default behavior if no other scaling is specified.

3. For an individual image, setting @contentwidth="scale-down-to-fit" in imagedata could work, since that attribute accepts CDATA (while @scalefit in DocBook 5 does not). Same for contentdepth. But what happens with this value in HTML output?

4. The global setting should be controlled by a param for backwards compatibility, but should there be separate params for content-width and content-height? I think so.

5. For global fallback, we already have an empty $default.image.width param which could be set to either value. We would have to add a $default.image.depth.

Any other thoughts or requirements?

Here is the current template that contains the logic for setting @content-width in the XSL-FO:

<xsl:template name="image.content.width">
  <xsl:param name="scalefit" select="0"/>
  <xsl:param name="scale" select="'1.0'"/>

  <xsl:choose>
    <xsl:when test="$ignore.image.scaling != 0">auto</xsl:when>
    <xsl:when test="contains(@contentwidth,'%')">
      <xsl:value-of select="@contentwidth"/>
    </xsl:when>
    <xsl:when test="@contentwidth">
      <xsl:call-template name="length-spec">
        <xsl:with-param name="length" select="@contentwidth"/>
        <xsl:with-param name="default.units" select="'px'"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:when test="number($scale) != 1.0">
      <xsl:value-of select="$scale * 100"/>
      <xsl:text>%</xsl:text>
    </xsl:when>
    <xsl:when test="$scalefit = 1">scale-to-fit</xsl:when>
    <xsl:otherwise>auto</xsl:otherwise>
  </xsl:choose>
</xsl:template>

I think adding these clauses after the second test would handle a specific instance:

<xsl:when test="@contentwidth = 'scale-down-to-fit'">scale-down-to-fit</xsl:when> <xsl:when test="@contentwidth = 'scale-up-to-fit'">scale-up-to-fit</xsl:when>

And this for default behavior, added before the $scale clause:

<xsl:when test="$default.image.width != ''"><xsl:value-of select="$default.image.width"/></xsl:when>

Does that look right?

--
Bob Stayton
Sagehill Enterprises
bobs@sagehill.net


On 1/6/2014 7:09 AM, David Cramer wrote:
Hi Mark,
I'd edit the fo and run it through your fo processor to confirm that
scale-down-to-fit gives the result you want.

For production you'll want to customize the templates from graphics.xsl
to make the right stuff come out in the fo. In particular the templates
<xsl:template name="image.content.width"> and <xsl:template
name="image.content.height"> are important.

Really this should be a feature of the stock xslts though.

Regards,
David

On 01/05/2014 03:58 AM, Mark Craig wrote:
Thanks Bob and David,

What's the right way to pass the "scale-down-to-fit" attribute value
into the FO?

I've tried adding them as attributes on <imagedata> with some XSL that I
was using before to handle wide images. Here's the template where
xmlns:db="http://docbook.org/ns/docbook"; exclude-result-prefixes="db":

  <xsl:template match="db:imagedata">
   <xsl:element name="imagedata" namespace="http://docbook.org/ns/docbook";>
    <xsl:apply-templates select="node()|@*"/>
    <xsl:attribute name="contentdepth">scale-down-to-fit</xsl:attribute>
    <xsl:attribute name="contentwidth">scale-down-to-fit</xsl:attribute>
    <xsl:attribute name="align">center</xsl:attribute>
   </xsl:element>
  </xsl:template>

After this transformation and running the stylesheets,
text-align="center" shows up in the resulting .fo, but the others are
null: content-width="" content-height="".

Is there a stylesheet customization I should apply to allow those
attribute values to pass through to the FO?

Or do I need to edit the FO after it gets generated?

Regards,
Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org







[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]