Pages: 1
Print
Author Topic: Graphic or image settings change  (Read 10484 times)
DITALearner
Member

Posts: 11


« on: September 29, 2010, 06:59:26 AM »

Hello everyone,

I am looking where to change image settings in DITA_OT\fo or DITA_OT\xmfo folder in the provided style sheets. I need to make changes to the width, height, text wrapping and image position on the body page.

Would someone know where to make these changes? If yes, please point me to the right direction.

I am transforming DITA to PDF using Xmetal Enhanched PDF via RenderX XEP and Book via RenderX.

Thanks for your assistance in advance
Logged
IF
Member

Posts: 80


« Reply #1 on: September 29, 2010, 08:55:03 AM »

I am not sure I understand the question. Are you saying that you want all your images to be the same size? If not, why not adjust the height and width of the figures from XMetal Author using the Image or Figure Properties dialog box?
Logged
DITALearner
Member

Posts: 11


« Reply #2 on: September 29, 2010, 09:18:01 AM »

Thanks IF,

Actually what I wanted to ask was if there is any general setting for images that affects all images during transformation to PDF. Since there are usually some global/common attributes.

Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #3 on: September 29, 2010, 12:28:52 PM »

You could perform a Find and Replace for all images in the current document if you want to set an attribute to a specific value that should be the same.

I'm not sure that's what you are asking for though, as it seems you're looking for something that will be added during transformation and not necessarily in the source XML. Is that right? What is it exactly that you want to add? Are we talking about styling (like a border?) or something else?
« Last Edit: September 29, 2010, 12:53:16 PM by Derek Read » Logged
DITALearner
Member

Posts: 11


« Reply #4 on: September 29, 2010, 01:05:26 PM »

You could perform a Find and Replace for all images in the current document if you want to set an attribute to a specific value that should be the same for all.

I'm not sure that's what you are asking for though, as it seems you're looking for something that will be added during transformation and not necessarily in the source XML. Is that right? What is it exactly that you want to add? Are we talking about styling (like a border?) or something else?

Yes, my source XML are OK with images properly inserted and displaying in Xmetal. They also get displayed properly when transformed into one-column, but when transformed into two-column, which is a requirement for the document I am working on, then I get some images too large to fit into one side of the columns. The resulting PDF is not properly formatted because of that.
Or sometimes the text wrapping around the images is not good, big gap between the surrounding text and the image.

I would like to keep my source XML intact, and perform changes only using the xslt during transformation.

So I was wondering if there is a way to make global change that can change affect all images at once during transformation.



Thank you.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #5 on: September 29, 2010, 05:35:23 PM »

What it sounds like you want is a setting that will automatically scale your images down (only?) to fit within the column they are contained inside of? If so setting the attribute called "outputclass" to "scale" on <image> should do that for you. Example:

<image href="test.jpg"
    height="1200px"
    width="1600px"
    id="image_7435C45A38734190AEF789075A5F71E0"
    placement="block"
    outputclass="scale">
    <alt>this is a test image</alt>
</image>


This is not standard DITA OT behavior for PDF output so it will only work in the "XMetaL Enhanced PDF via RenderX XEP" deliverable. Also, as written, you need to set this value on all of your <image> elements.

You could probably change that fairly easily though (provided you have some understanding of XSLT / XSL-FO) so that it does this for all images regardless of attribute or value, or if you wish to change the attribute value or name that is being checked (ie: rather than "scale" you want to use "foobar" or another attribute rather than outputclass). The file containing this code is located here:

%appdata%\SoftQuad\XMetaL Shared\DITA_OT\demo\xmfo\Customization\fo\xsl\xm_image_size_fix.xsl

I'm not sure about columns but this certainly works for pages. However, given the way it is coded I would expect it to work for columns as well. Note that it assumes an image DPI of 96 when doing necessary conversions so if things look wacky there (ie: perhaps you have some 72 DPI images, etc) that's what you'll probably need to look at.
« Last Edit: September 29, 2010, 05:38:33 PM by Derek Read » Logged
DITALearner
Member

Posts: 11


« Reply #6 on: September 30, 2010, 07:56:14 AM »

Thanks Derek,

Could you provide an example for all images as my coding skills are very limited. I just tested the solution and it did work fine.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #7 on: September 30, 2010, 02:46:00 PM »

Officially we are not aiding people with making changes to the DITA OT (this type of thing is typically redirected to our partners as a paid engagement). However, as this is likely to be useful for others and it might be simple I'll see what it might take to enable it (assuming I have some time to spare from my other duties).
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #8 on: September 30, 2010, 03:53:47 PM »

OK, the following change will force images to be 100% (their original size as encoded in the image itself) regardless of what you set for their width or height attribute values (in the XML source) AND if the image is too big to fit inside its containing block (in your case this is essentially the column width) then they should be scaled down to fit -- the feature you are looking for. This is working for me with raster images (tested with JPG and GIF).


Deliverable type:
"XMetaL Enhanced PDF via RenderX XEP"
File: ..\DITA_OT\demo\xmfo\Customization\fo\xsl\xm_image_size_fix.xsl

Original template:
    <xsl:template name="placeImage">
        <xsl:param name="imageAlign"/>
        <xsl:param name="href"/>
        <xsl:param name="height"/>
        <xsl:param name="width"/>
        <!--Using align attribute set according to image @align attribute-->
        <xsl:call-template name="processAttrSetReflection">
            <xsl:with-param name="attrSet" select="concat('__align__', $imageAlign)"/>
            <xsl:with-param name="path" select="'../attrs/xm-cfg/commons-attr.xsl'"/>
        </xsl:call-template>
        <xsl:choose>
            <xsl:when test="@outputclass='scale'"><!-- scale the image -->
                <fo:block line-height="1pt">
                    <fo:external-graphic src="url({$href})" content-width="scale-to-fit" content-height="100%" width="100%" scaling="uniform" />
                </fo:block>
            </xsl:when>
            <xsl:otherwise>
                <fo:external-graphic src="url({$href})" xsl:use-attribute-sets="image">
                    <!--Setting image height if defined-->
                    <xsl:if test="$height">
                        <xsl:attribute name="content-height">
                            <xsl:choose>
                                <xsl:when test="not(string(number($height)) = 'NaN')">
                                    <xsl:value-of select="concat($height div 96,'in')"/>
                                </xsl:when>
                                <xsl:when test="$height">
                                    <xsl:value-of select="$height"/>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:attribute>
                    </xsl:if>
                    <!--Setting image width if defined-->
                    <xsl:if test="$width">
                        <xsl:attribute name="content-width">
                            <xsl:choose>
                                <xsl:when test="not(string(number($width)) = 'NaN')">
                                    <xsl:value-of select="concat($width div 96,'in')"/>
                                </xsl:when>
                                <xsl:when test="$width">
                                    <xsl:value-of select="$width"/>
                                </xsl:when>
                            </xsl:choose>
                        </xsl:attribute>
                    </xsl:if>
                </fo:external-graphic>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


New template:
    <xsl:template name="placeImage">
        <xsl:param name="imageAlign"/>
        <xsl:param name="href"/>
        <xsl:param name="height"/>
        <xsl:param name="width"/>
        <!--Using align attribute set according to image @align attribute-->
        <xsl:call-template name="processAttrSetReflection">
            <xsl:with-param name="attrSet" select="concat('__align__', $imageAlign)"/>
            <xsl:with-param name="path" select="'../attrs/xm-cfg/commons-attr.xsl'"/>
        </xsl:call-template>

        <!-- scale all images -->
        <fo:block>
            <fo:external-graphic src="url({$href})" content-width="scale-to-fit" content-height="100%" width="100%" scaling="uniform" />
        </fo:block>

    </xsl:template>


For those that wish to dig into this further the following file both defines and calls the template called "placeImage" that is being redefined in the file listed above:
..\DITA_OT\demo\xmfo\xsl\fo\commons.xsl

The reason it was redefined in the first place is because the original DITA OT plug-in that our plug-in is based on (from Idiom, sometimes called the "PDF2" transtype) is that it assumed images would be coded at 72 DPI (72 pixels per inch, which is standard on some operating systems like Macs). As our software runs on Windows where 96 DPI is the standard display resolution we changed this to 96, so that what you see while editing would match what you see in output. For more information on the complexities of embedding raster images into PDF documents at the "right" resolution you may wish to search the web for "pdf image resolution" (the main point being that there really is no "right" resolution).
« Last Edit: September 30, 2010, 04:04:45 PM by Derek Read » Logged
DITALearner
Member

Posts: 11


« Reply #9 on: October 01, 2010, 06:50:32 AM »

Thanks a lot Derek,

I just made the change and it worked fine with the document I have at the moment. This really helps.

Can we use these same settings on the "Book via RenderX" profile? In other words what are the files that need to be changed in the %AppData%SoftQuad\XMetaL Shared\DITA_OT\demo\fo folder to produce the same behavior?

Once again, thank you for your support.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #10 on: October 01, 2010, 03:23:05 PM »

Book via RenderX doesn't have the same file in place to modify so the fix would be different but since all our file has done is to override this template it might not be too different.

You'd likely need to make a similar (or perhaps even exactly the same) change to this file (though the location of the template will be on a different line):
..\DITA_OT\demo\fo\xsl\fo\commons.xsl

Can I ask why you need to produce PDF using both deliverables? I'm not sure I understand why that would be the case as most clients decide to customize one and then use it as the basis for all their PDF outputs.
« Last Edit: October 01, 2010, 03:27:52 PM by Derek Read » Logged
DITALearner
Member

Posts: 11


« Reply #11 on: October 01, 2010, 03:30:59 PM »

Thanks again Derek for your follow up.

Actually, I have a set of documents that need to be transformed using the same approach but via "Book via RenderX". For those, I already some customized style sheets and was wondering if it could be done. At least if I could be directed to the right set of files to modify for the same effect.

Regards.
Logged
IF
Member

Posts: 80


« Reply #12 on: March 26, 2013, 08:53:58 PM »

I made the template change suggested by Derek. It works well for me except that the placement attribute value is ignored when it is set at inline. All my images have a break whether I want one or not.  I tried a few things wiht the template but could not resolve this issue. Any thoughts? Thanks. Isabelle
Logged
IF
Member

Posts: 80


« Reply #13 on: March 27, 2013, 03:03:51 PM »

Problem fixed -
<xsl:when test="not($placement='inline')"><!-- scale the image -->
                <fo:block line-height="1pt">
                    <fo:external-graphic src="url({$href})" content-width="scale-to-fit" content-height="100%" width="100%" scaling="uniform" />
                </fo:block>
            </xsl:when>
Logged
Pages: 1
Print
Jump to:  

email us