Forum How do I...?

getBBox issue in SVG with embedded javascript

mircea.baicu
hey Guys,

I have a small issue regarding getBBox function.

I have some javascript embedded in my SVG, and I am using the getBBox function. When I run the SVG in the browser all goes well, but when I try to make a conversion from SVG to PDF with prince it does not work as it should.

Here is a simple example:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" width="297.64px" height="420.94px" viewBox="0 0 297.64 420.94" enable-background="new 0 0 297.64 420.94" xml:space="preserve">
<g>
	<rect x="0.719" y="72.696" fill="none" width="298.474" height="58.291"/>
	<text id="happy" transform="matrix(1 0 0 1 52.8584 101.5439)" fill="#8F3F91" font-size="47" data-position="52 101 193">Happy Birthday</text>
</g>
<script><![CDATA[
	var happy = document.getElementById('happy');
	var bbox = happy.getBBox();
	console.log(bbox.x + ' -- ' + bbox.y + ' -- ' + bbox.width + ' -- ' + bbox.height);
]]></script>
</svg>

And I make the conversion using: "prince input.svg -o output.pdf --javascript"

so the javascript is ran before the conversion.

Any help in getting the getBBox to return some values would be appreciated.
mikeday
Unfortunately Prince does not support getBBox in the SVG DOM yet. We need to add this in order to support more dynamic layout scripts. I will add it to the development roadmap.
mircea.baicu
Thanks for your response, that is good to know.

I tried putting the JS code into an external JS file which I included in the command with "-script myJsFile.js" but still no luck. It's the same issue ?

Cheers,
Mircea
mikeday
Same issue, Prince doesn't support this method yet, no matter where it is called from.