DocumentationPagesOn-demand documents

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 sendYou getPathCan return 429
XMLPDFpdf/createYes
JSONPDFpdf/create/jsondataNo
DXMLPDFpdf/create/dxmlNo
XMLPDF, simplexpdf/simplex/createYes
JSONPDF, simplexpdf/simplex/create/jsondataNo
DXMLPDF, simplexpdf/simplex/create/dxmlNo
XMLPDF with a Draft stamppdf/createpreviewNo
JSONPDF with a Draft stamppdf/createpreview/jsondataNo
XMLHTMLhtml/createNo
JSONHTMLhtml/create/jsondataNo
DXMLHTMLhtml/create/dxmlNo
XMLMFDXmfdx/createYes
JSONMFDXmfdx/create/jsondataYes
XMLMFDX, simplexmfdx/simplex/createYes
JSONMFDX, simplexmfdx/simplex/create/jsondataYes
XMLAXML (an XML file)xml/createNo
JSONAXML (an XML file)xml/create/jsondataNo

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:

FieldRequiredMeaning
MetaFileYesThe name of the logic file.
DocumentYesThe document template inside the logic file.
DataAsBase64YesThe XML or JSON data as a base64 string.
AttributeStoreKeyNoA key in the CenterPoint Attribute Store. Its metadata is merged with your data.
SourceNoThe name of the calling system in Statistics.
AttachmentsNoA 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:

FieldRequiredMeaning
B64DxmlYesThe DXML as a base64 string.
B64DataNoXML data as a base64 string.
AttributeStoreKeyNoAs above.
SourceNoAs above.
AttachmentsNoAs above. Not for HTML.
MetaFile and DocumentHTML onlyThe 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.

CodeMeaning
200The file.
204The data should not produce a document. There is no body.
406Something is missing in the logic file. The body is JSON with a Message field.
429Too 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:

TypeWhat it isFields you set
MFLAn attachment that is published from a logic file.MetaFile and Document
PDFA PDF that you send. Pages converts it to AXML.FileAsBase64, Pdf2AxmlOptions, and optionally PageRanges
AXMLAn 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:

FieldMeaningDefault
DuplexWhether the document is duplex.false
DpiThe resolution of the converted images.150
ColorDepthBW 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:

ErrorCause
(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}/attachments

Returns 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" }