As mentioned earlier, the "job" chunk contains a description of the conversion job represented in JSON format, which can be followed by an optional sequence of "dat" chunks containing file data which is needed by the job, eg. HTML documents, style sheets, PDF attachments, or whatever.
The number of "dat" chunks is specified by the "job-resource-count" field in the job description, and these files can be accessed via a special job-resource URL scheme, eg. job-resource:0 will access the content of the first "dat" chunk, then job-resource:1, job-resource:2, etc. This allows any number of resources to be provided inline with the request and removes the need to create actual temporary files.
The JSON job description has several nested objects with fields corresponding to Prince options:
{
"input": { <input options> },
"pdf": { <pdf options> },
"metadata": { <metadata options> },
"raster": { <raster options> },
"job-resource-count": <int>
}
The input options and job-resource-count are mandatory, the rest are optional and will default to the normal values.
The input options includes these fields:
{
"src": <single URL or list of URLs>,
"type": <string>,
"base": <string>,
"media": <string>,
"styles": [ <list of URLs> ],
"scripts": [ <list of URLs> ],
"default-style": <bool>,
"author-style": <bool>,
"javascript": <bool>,
"xinclude": <bool>,
"xml-external-entities": <bool>
}
Only the src field is required, the rest can be left as defaults.
Now we can make some simple job descriptions, eg. to convert a single HTML file:
{
"input": {
"src": "/path/to/input.html"
},
"job-resource-count": 0
}
This can be sent as a single "job" chunk and Prince will respond with a "pdf" chunk if the conversion succeeded and a "log" chunk.
Or you can convert a HTML document without saving it to a temporary file:
{
"input": {
"src": "job-resource:0"
},
"job-resource-count": 1
}
This requires the "job" chunk to be followed by a "dat" chunk that contains the HTML and then Prince will respond as before.