Forum Bugs

The --script option fails unless --javascript is enabled.

rhall
The docs at http://www.princexml.com/doc/8.1/javascript/ say,
"External scripts can be run by specifying --script=FILE options on the command-line. These scripts will always be executed, regardless of whether document scripts have been enabled or not."

For me, code in an external file won't execute unless I include the --javascript option in addition to the --script=FILE option. I get several "prince: warning: JavaScript is disabled" error messages.

I want to run my external JavaScript code, but I don't want to run any of the scripts in the source HTML document. Does Prince support that?

I'm running Prince 8.1 rev 3 from a command prompt in Windows XP.
mikeday
Are you using the prince-script() extension in CSS generated content? Currently this requires JavaScript to be enabled in order to execute.
rhall
Are you using the prince-script() extension in CSS generated content?

Yes, to get the current date.

Is there a way to get the date and also prevent JavaScript in the source HTML document from executing? I don't want to edit the source doc at all. (I'm looking for a way to auto-generate PDFs from company web/wiki pages, which may include JavaScript.)

Thanks,
-rh
mikeday
How about using the --script option to trigger an external script that embeds the current date directly in the markup, instead of calling it via prince-script(). For example, something like this:
currDate = new Date().toString();
document.getElementById("date").textContent = currDate;

With the document containing:
<span id="date"></span>
rhall
The external function does indeed work without the --javascript option (thanks!), but now other prince-script() calls in the CSS file don't execute.

That's not a show-stopper in this case. I was experimenting with prince-script() to fetch text for page headers and footers, but I can just hard-code that text in the CSS. That's probably a better approach, anyway.
rhall
Just to follow up: I'm finding that prince-script() calls in the CSS file don't execute unless I include the --javascript option on the command line in addition to the --script option.

Here's the command (in Windows XP) without the --javascript option:
prince.exe -i html5 --no-author-style --insecure --baseurl=https://wiki.xxx.com --script=xxx.js --style=xxx.css xxx.html --output=xxx.pdf

I get this message:
prince: warning: JavaScript is disabled

When I include the --javascript option, prince-script() calls do execute.

Is that the expected behavior?
mikeday
This is the current behaviour, as currently Prince does not track whether the prince-script() call comes from a document style sheet or a separately applied user style sheet, so all of them are disabled unless --javascript is switched on. We may change this in a future release.