Hi Michael,

Batik can only convert static SVG content to SVG as there is no easy 1:1 transformation from an interactive SVG to an interactive PDF.

While there might be some overlap in the interactivity options of both formats they don't match too closely.

The only thing Batik can do regarding scripts, is to run onload scripts to manipulate the SVG DOM prior to conversion, e.g. to pull in some database stuff or place stuff according to some logic.

Andreas

Michael Brohm wrote:

I have a simple SVG file with some JavaScript in it, and I want to create a PDF file from it. I use PDFTranscoder to convert it and it creates the PDF file fine, but none of the JavaScript runs in the PDF. Has anyone else run into this issue? Any help would be greatly appreciated.
Here is the code:

                         PDFTranscoder t = new PDFTranscoder();

String svgURI = new File(args[0]).toURL().toString();

TranscoderInput input = new TranscoderInput(svgURI);

OutputStream ostream = new FileOutputStream("out.pdf");

TranscoderOutput output = new TranscoderOutput(ostream);

                         // Perform the transcoding.

                         t.transcode(input, output);

                         ostream.flush();

                         ostream.close();

                        System.exit(0);

And here is the svg:

<?xml version="1.0" standalone="no"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"

  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd";>

<svg onload="init(evt)" xml:space="preserve" width="130" height="200" viewBox="0 0 130 200" xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns="http://www.w3.org/2000/svg"; preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify">

                <!-- Matthew Bystedt http://apike.ca 2005 -->

    <script type="text/ecmascript"><![CDATA[

    function init(evt) {

        if ( window.svgDocument == null )

            svgDocument = evt.target.ownerDocument;

    }

    var click       = 0;

    var mouseDown   = 0;

    var mouseUp     = 0;

    var mouseOver   = 0;

    var mouseMove   = 0;

    var mouseOut    = 0;

    function updateStats() {

svgDocument.getElementById("clicks").firstChild.data = "onclick = " + click;

svgDocument.getElementById("mousedowns").firstChild.data = "onmousedown = " + mouseDown;

svgDocument.getElementById("mouseups").firstChild.data = "onmouseup = " + mouseUp;

svgDocument.getElementById("mouseovers").firstChild.data = "onmouseover = " + mouseOver;

svgDocument.getElementById("mousemoves").firstChild.data = "onmousemove = " + mouseMove;

svgDocument.getElementById("mouseouts").firstChild.data = "onmouseout = " + mouseOut;

    }

    function msClick (evt) {

        click++;

        updateStats();

    }

    function msDown (evt) {

        mouseDown++;

        updateStats();

    }

    function msUp (evt) {

        mouseUp++;

        updateStats();

    }

    function msOver (evt) {

        mouseOver++;

        updateStats();

    }

    function msMove (evt) {

        mouseMove++;

        updateStats();

    }

    function msOut (evt) {

        mouseOut++;

        updateStats();

    }

    ]]></script>

                <!-- Pattern Definition -->

                <defs>

<pattern id="checkerPattern" patternUnits="userSpaceOnUse" x="0" y="0" width="10" height="10" viewBox="0 0 10 10" preserveAspectRatio="xMidYMid meet">

<rect x="0" y="0" width="5" height="5" fill="lightblue"/>

<rect x="5" y="5" width="5" height="5" fill="lightblue"/>

                                </pattern>

                </defs>

                <!-- Background -->

<rect x="0" y="0" width="100%" height="100%" fill="url(#checkerPattern)"/>

                <!-- Javascript Example -->

<circle cx="50%" cy="25%" r="40" fill="lightyellow" stroke-width="1" stroke="black" onclick="msClick()" onmousedown="msDown()" onmouseup="msUp()" onmouseover="msOver()" onmousemove="msMove()" onmouseout="msOut()"/>

<rect x="5" y="95" width="120" height="95" fill="white" stroke="grey" stroke-width="2" rx="10" ry="10" opacity="0.5"/>

    <text x="10" y="110" id="clicks" startOffset="0">onclick = 0</text>

<text x="10" y="125" id="mousedowns" startOffset="0">onmousedown = 0</text>

<text x="10" y="140" id="mouseups" startOffset="0">onmouseup = 0</text>

<text x="10" y="155" id="mouseovers" startOffset="0">onmouseover = 0</text>

<text x="10" y="170" id="mousemoves" startOffset="0">onmousemove = 0</text>

<text x="10" y="185" id="mouseouts" startOffset="0">onmouseout = 0</text>
</svg>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to