Forum Bugs

JS file doesn't get included in PrinceXML command line, but it gets included in PrinceXML GUI

Ehart
For example, I have the following CSS, called foobar.css:

@page foobar{
    @bottom-right {
        content: prince-script(myfunc)
    }
}


The javascript file, called foobar.js is:

function myfunc() {
    return "Generated content from Javascript!";
}

Prince.addScriptFunc("myfunc", myfunc);


And in HTML, called foobar.html I add them both:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="foobar.css">
        <script src="foobar.js"></script>
    </head>
    <body>
 [..]


When I add the file foobar.html to the PrinceGUI and click on the convert button, I see in the PDF output "Generated content from Javascript!" in the bottom of the page foobar.
When I do the same with the PrinceXML command line on windows 7 x64 (prince.exe is located in the PATH),

"prince foobar.html -o foobar.pdf"

I see the same, the DOM structure and CSS-stylesheet are applied in the foobar.pdf. But the generated Javascript "Generated content from Javascript!" is missing in the foobar.pdf.
When I add the SAME file foobar.html to the PrinceGUI and convert it, the text from Javascript will appear. But is missing when I do the same on the command line.

Edited by Ehart

mikeday
Pass the --javascript option on the command-line to enable JavaScript.
Ehart
Thanks, it did do the trick. However, I don't pass any javascript file in the PrinceXML GUI. So I`m wondering why PrinceXML GUI enabled the javascript, while the same prince.exe on command line didn`t it.

So the PrinceXML GUI must be aware if there is any Javascript file included in the HTML file, and then enable the --javascript option?

Or is --javascript option enabled by default in the code of PrinceXML GUI?
mikeday
JavaScript is enabled by default in the GUI, for convenience. :)
Ehart
Ah, I get it. Thanks. Then this is not a bug. :-)