[xep-support] [HOW-TO] Embed multimedia (Flash) in PDFs through oXygen and XEP

Gibbons, Dave (Hillsboro) David.Gibbons at Fiserv.com
Fri Aug 20 13:48:35 PDT 2010


Kevin Brown at RenderX asked me to post this solution, also posted to DITA-USERS at Yahoo.

My company uses oXygen and the DITA-OT to produce documentation in XHTML and PDF. We're starting to use Flash on the XHTML side. One of the content producers I work with asked if we could use Flash in PDF, which seemed reasonable, since PDF supports Flash. The DITA-OT, however, was having none of it.

I spoke with Radu Coravu at SyncRO Soft (oXygen, oxygenxml.com) about this, and he came up with a neat solution. Here is his message, followed by some additional tweaking I did.

---------------

Oxygen uses the DITA Open Toolkit to process DITA Maps and Topics to different output formats.

You are using an older version of Oxygen which is bundled with DITA OT 1.4.3. [EDIT: I had replaced that version with 1.5, but Radu didn't know that. -DG] This older version of Oxygen also has the particularity that the topic to PDF transformation is not performed using the DITA OT ANT scripts but by applying a stylesheet. So for example if in your topic you have content references they will not show up correctly if the topic gets transformed directly to PDF. But if you transform a DITA Map in the DITA Maps Manager view which links to this topic, the output should be correct.

But from what I see (not even in the newest DITA OT version) the DITA to PDF output does not treat <object> elements at all when building the FO file.

For example open in Oxygen the following file:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/commons.xsl

It has a template  which matches objects:

<xsl:template match="*[contains(@class,' topic/object ')]"> <fo:inline xsl:use-attribute-sets="object" id="{@id}"> </fo:inline> </xsl:template>

but which does not output anything from them. You can try changing this template to something like:

<xsl:template match="*[contains(@class,' topic/object ')]"> <fo:block xsl:use-attribute-sets="object" id="{@id}"> <rx:media-object xmlns:rx="http://www.renderx.com/XSL/Extensions"
             src="{@data}"
             embed="true"
             content-width="{@width}px"
             content-height="{@height}px"
             content-type="auto"
             show-controls="true"/>
</fo:block>
</xsl:template>

The transformation should then produce a FO output which contains the extension object specified correctly.

Regards,
Radu Coravu
<oXygen/>   XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

---------------

I made that change ran the transformation through XEP to produce a PDF. It worked perfectly.

Here is the code I used in the XML source file:

     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
         codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
         data="url(file:///c:\pdf2\movie1.swf)"
         type="application/x-shockwave-flash"
         height="800"
         width="1000"
         id="movie1">
         <desc>A description of the task</desc>
         <param name="movie" value="c:\pdf2\movie1.swf"/>
         <param name="quality" value="high"/>
         <param name="bgcolor" value="#FFFFFF"/>
     </object>

The problem I found was that the Flash content dimensions the content producers preferred for the Web were too wide for our default PDF pages. I added attributes to the <object> element ("pdfheight" and "pdfwidth") in commonelementsmod.xsd and commonelements.mod, and changed Radu's code in commons.xsl to output those values instead of the regular height and width values.

    content-width="{@pdfwidth}px"
    content-height="{@pdfheight}px"

I added these attributes to the <object> element above:

    pdfheight="650"
    pdfwidth="800"

That worked perfectly, too. The DITA source files validate correctly in oXygen and ANT, and the FO file that is produced works seamlessly with XEP.

I suspect a more elegant solution would be to scale the height and width values in the XSLT, and I'll probably try that next. Ideas and feedback welcome, of course.

The PDFs look beautiful through XEP, and the multimedia elements (screen shots with mouseovers, mostly) are getting raves from everyone who sees them.

-Dave Gibbons
Fiserv

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.renderx.com/pipermail/xep-support/attachments/20100820/dd852033/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 92 bytes
Desc: image001.gif
URL: <http://lists.renderx.com/pipermail/xep-support/attachments/20100820/dd852033/attachment.gif>


More information about the Xep-support mailing list