On-demand documents
Use an on-demand call to get a finished document back in one call, without an Editor session. You send the data, Pages builds the document from the template in your logic file, and the response is the file.
The common parts of every call, such as the path, the token and the response codes, are on Calling the Pages API. Paths on this page leave out the optional environment group.
Choose a format
Pick the endpoint by the data you have and the file you want. Every endpoint is a POST to /{customerEnvironment}/ followed by the path
in the table.
| You send | You get | Path | Can return 429 |
|---|---|---|---|
| XML | pdf/create | Yes | |
| JSON | pdf/create/jsondata | No | |
| DXML | pdf/create/dxml | No | |
| XML | PDF, simplex | pdf/simplex/create | Yes |
| JSON | PDF, simplex | pdf/simplex/create/jsondata | No |
| DXML | PDF, simplex | pdf/simplex/create/dxml | No |
| XML | PDF with a Draft stamp | pdf/createpreview | No |
| JSON | PDF with a Draft stamp | pdf/createpreview/jsondata | No |
| XML | HTML | html/create | No |
| JSON | HTML | html/create/jsondata | No |
| DXML | HTML | html/create/dxml | No |
| XML | MFDX | mfdx/create | Yes |
| JSON | MFDX | mfdx/create/jsondata | Yes |
| XML | MFDX, simplex | mfdx/simplex/create | Yes |
| JSON | MFDX, simplex | mfdx/simplex/create/jsondata | Yes |
| XML | AXML (an XML file) | xml/create | No |
| JSON | AXML (an XML file) | xml/create/jsondata | No |
A simplex document is meant for single-sided printing.
HTML is only available for documents that have a Content template in the logic file.
The Draft stamp on a preview PDF marks the document as not final. Use it to show the user what the document will look like.
Send the request
For XML and JSON data, the body has the same fields on every endpoint:
| Field | Required | Meaning |
|---|---|---|
MetaFile | Yes | The name of the logic file. |
Document | Yes | The document template inside the logic file. |
DataAsBase64 | Yes | The XML or JSON data as a base64 string. |
AttributeStoreKey | No | A key in the CenterPoint Attribute Store. Its metadata is merged with your data. |
Source | No | The name of the calling system in Statistics. |
Attachments | No | A list of attachments. The HTML endpoints do not take attachments. |
This example sends JSON data, so it goes to a jsondata endpoint such as pdf/create/jsondata:
{
"MetaFile": "OrderConfirmations",
"Document": "OrderConfirmation",
"DataAsBase64": "eyJjdXN0b21lciI6Ik5vcmRseXMgQVMiLCJudW1iZXIiOjEwMDQyfQ=="
}The endpoints that start from DXML take these fields instead:
| Field | Required | Meaning |
|---|---|---|
B64Dxml | Yes | The DXML as a base64 string. |
B64Data | No | XML data as a base64 string. |
AttributeStoreKey | No | As above. |
Source | No | As above. |
Attachments | No | As above. Not for HTML. |
MetaFile and Document | HTML only | The logic file and the document that holds the Content template. |
Read the response
The response body is the file, with the extension .pdf, .html, .mfdx or .xml. For XML and JSON data its name is made from the
logic file, the document and a new unique value. For DXML the name is only a new unique value.
| Code | Meaning |
|---|---|
| 200 | The file. |
| 204 | The data should not produce a document. There is no body. |
| 406 | Something is missing in the logic file. The body is JSON with a Message field. |
| 429 | Too many calls. See Rate limits. |
MFDX layout
The MFDX format is a really simple format that contains PDF and metadata in XML format in one package. The file starts with 1 byte that reveals the format followed by a 4 byte long length indicator followed by the PDF bytes. This is followed by another 4 byte long length indicator and the XML in UTF8 encoding. The length indicators are in big-endian byte order, and each attribute of the XML element is one metadata value.
Attachments
A document can carry attachments. Each item in Attachments has a Type of MFL, PDF or AXML:
| Type | What it is | Fields you set |
|---|---|---|
MFL | An attachment that is published from a logic file. | MetaFile and Document |
PDF | A PDF that you send. Pages converts it to AXML. | FileAsBase64, Pdf2AxmlOptions, and optionally PageRanges |
AXML | An AXML file that you send. It must be in short-name format. | FileAsBase64, and optionally PageRanges |
All types also take Name, Order (the place in the list) and SubstituteData, which says whether your data is filled into the
attachment (default true).
PageRanges selects which pages to use. Each range has a Start and an End page number, counted from 1.
Pdf2AxmlOptions tells Pages how to convert a PDF:
| Field | Meaning | Default |
|---|---|---|
Duplex | Whether the document is duplex. | false |
Dpi | The resolution of the converted images. | 150 |
ColorDepth | BW or Color. | BW |
{
"MetaFile": "OrderConfirmations",
"Document": "OrderConfirmation",
"DataAsBase64": "eyJjdXN0b21lciI6Ik5vcmRseXMgQVMiLCJudW1iZXIiOjEwMDQyfQ==",
"Attachments": [
{
"Type": "PDF",
"Name": "Terms",
"Order": 1,
"FileAsBase64": "JVBERi0xLjQK...",
"PageRanges": [ { "Start": 1, "End": 2 } ],
"Pdf2AxmlOptions": { "Duplex": false, "Dpi": 150, "ColorDepth": "BW" }
}
]
}PDF and AXML attachments are part of newer versions of Pages. If your environment does not accept them, it is on an older version.
A PDF and an AXML attachment each have a size limit, and the DXML and all attachments together have one too. See Limitations. These errors can come back with an attachment:
| Error | Cause |
|---|---|
| (075) | A required field is empty, such as FileAsBase64 or Pdf2AxmlOptions. |
| (076) | The published attachment for the MetaFile and Document cannot be found. |
| (077) | A page number in PageRanges is not a positive number. |
| (078) | The start page in a page range is after its end page. |
| (079) | The AXML attachment is not in short-name format. |
| (080) | The attachment is over the size limit. |
List published attachments
POST /{customerEnvironment}/attachmentsReturns the metadata of the published attachments that match the search in the body. Top is required and sets the most rows to
return. Id must match exactly. Name, Description and Group match as a partial text, and an empty field is left out of the search.
Each result has Id, Name, Group, Description, MetaLogic, DocumentName, SaveTime and UserID.
{ "Top": 20, "Group": "Terms" }