Forum How do I...?

Throwing Javascript Errors to Halt PDF Generation


When generating PDFs with prince I have an xhtml that fires off some javascript to dynamically create parts of the document. Is there a way to halt PDF generation through javascript when an error occurs? I've tried throwing errors in the script: throw new Error("An error has occurred"), but the document still generates.

Here is what gets printed out to the console:
prince: http://localhost:63342/reporting-services-master/reporting-services-authoring/injector.js: error: Error: UNABLE_TO_RENDER_VISUAL_COMPONENT_ERROR, unable to render visual component with id: kf.enterprise.radarChart

I am using prince 10rev7 on MacOSX for local dev but deploy to a linux environment on production.

Actually there is no way to halt document conversion from JavaScript. Now that you mention it, we should probably consider adding an API for this purpose. For now, you can emit a log message that gets detected by the caller, to tell it to ignore the generated PDF.
Thanks for the reply. For now I'm just looking for a particular string in stderr and then throwing an exception at the application level.