PDF and other outputs
These calls produce a finished document from your data without an editor session. The document comes back in the response. To start an editing session instead, see Create documents.
Every path starts with the environment, for example /Test/pdf/create, on the host api.webeditor-v4.metaforce.net. See Hosts and environments for the values.
The outputs
Each output with XML data has a twin for JSON data. Add /jsondata at the end of the path. The body is the same.
| Path | Returns |
|---|---|
POST /pdf/create | A PDF. |
POST /pdf/simplex/create | A PDF that is printed on one side only. |
POST /pdf/createpreview | A preview PDF. |
POST /mfdx/create | An MFDX file, a PDF with its metadata in XML. |
POST /mfdx/simplex/create | An MFDX file for one-sided printing. |
POST /html/create | HTML. The MetaFile must have a content template for the document. |
POST /xml/create | The document as XML. |
POST /dynamo/create | Creates the document in Dynamo instead of returning a file. See Store and find documents. |
A few calls take a DXML instead of data:
| Path | Returns |
|---|---|
GET /pdf/dxml/{dxmlUID} | A PDF from a session in storage. Use it when editing is finished. |
GET /pdf/simplex/dxml/{dxmlUID} | The same, for one-sided printing. |
POST /pdf/create/dxml | A PDF from a DXML that you send in the body. |
POST /pdf/simplex/create/dxml | The same, for one-sided printing. |
POST /html/create/dxml | HTML from a DXML that you send in the body. |
GET /html/dxml/{dxmlUID}, GET /xml/dxml/{dxmlUID} | HTML or XML from a session in storage. 404 if there is none. |
Request body
The data calls take the body described under DXML, without the callback fields:
| Field | What it is |
|---|---|
MetaFile, Document | Which document to produce. Required. |
DataAsBase64 | The XML or JSON data as a base64 string. Required. |
AttributeStoreKey, Source | Optional, as for a DXML. |
Attachments | Optional. A list of attachments, see Attachments. The HTML calls do not take attachments. |
{
"DataAsBase64": "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz4K...",
"Document": "CaseLetter2 - Online",
"MetaFile": "CompanyLetters"
}Answers
200with the file.204when the data should not produce a document.406when the data cannot be produced because logic is missing in the MetaFile.429when you send too many requests at once. These calls are rate limited:pdf/createandpdf/simplex/createwith XML data, allmfdxcalls anddynamo/createwith XML or JSON data. Wait and try again.
Example
Use the API host of your Pages version from Hosts and environments as baseUrl.
const axios = require('axios').default;
const fs = require('fs');
const baseUrl = 'https://<Pages API host>';
async function createPdf(accessToken) {
const xml = "<?xml version='1.0' encoding='utf-8'?><Data><Contact ContactFirstName=\"Ingrid\" /></Data>";
const response = await axios({
method: 'POST',
url: baseUrl + '/Test/pdf/create',
headers: {
'content-type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
data: {
MetaFile: 'CompanyLetters',
Document: 'CaseLetter2 - Online',
DataAsBase64: Buffer.from(xml).toString('base64')
},
responseType: 'arraybuffer'
});
if (response.status === 204) {
console.log('No document was produced for this data');
return;
}
fs.writeFileSync('letter.pdf', response.data);
}