Information Classification: External Restricted.
See https://www.chili-publish.com/security

Document Output via Javascript

Concept

Usually, document output (most often PDF files) is generated either on server-side (using the API, with functions like DocumentCreatePDF), or on client-side from within the Editor itself (e.g: using the Output toolbar item).
It is however also possible to trigger this output from JavaScript. 

PDF and Image Output

To initiate PDF creation or image output, you will first need to get the Definition XML of a PDF Export Settings, possibly done via an ajax call which executes the webservice function "ResourceItemGetXML". 
The resulting XML is used as a string argument to the various functions.

Generating a PDF can be initiated using the CreateTempPDF_FromXml function. This function will:

  • serialize the current state of the document (generating a "temporary" XML of the document, without actually saving it on the server)
  • call the DocumentCreateTempPDF function
  • wait for the background task to complete
  • open the generated PDF file in the requested iframe
  • trigger the "/wiki/spaces/CPDOC/pages/1413058" event

Actually calling the PDF generation can be done using: 

editor.ExecuteFunction("document","CreateTempPDF_FromXml",pdfSettingsXML,"_blank")

 

Similarly, Image Output can be generated using:

editor.ExecuteFunction("document","CreateTempImages_FromXml",pdfSettingsXML,imgConversionProfileID)

 

Temporary XML

To get the XML of the document that is open in the editor, you can call

editor.ExecuteFunction("document", "GetTempXML");

This function will return you the document's XML in its current state, so there is no need to save the document.
This XML could be used to create a new (version of the current) document, possibly done via an AJAX call that executes the webservice function "ResourceItemAdd".

All information on this page must be treated as External Restricted, or more strict. https://www.chili-publish.com/security