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.

PathReturns
POST /pdf/createA PDF.
POST /pdf/simplex/createA PDF that is printed on one side only.
POST /pdf/createpreviewA preview PDF.
POST /mfdx/createAn MFDX file, a PDF with its metadata in XML.
POST /mfdx/simplex/createAn MFDX file for one-sided printing.
POST /html/createHTML. The MetaFile must have a content template for the document.
POST /xml/createThe document as XML.
POST /dynamo/createCreates the document in Dynamo instead of returning a file. See Store and find documents.

A few calls take a DXML instead of data:

PathReturns
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/dxmlA PDF from a DXML that you send in the body.
POST /pdf/simplex/create/dxmlThe same, for one-sided printing.
POST /html/create/dxmlHTML 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:

FieldWhat it is
MetaFile, DocumentWhich document to produce. Required.
DataAsBase64The XML or JSON data as a base64 string. Required.
AttributeStoreKey, SourceOptional, as for a DXML.
AttachmentsOptional. A list of attachments, see Attachments. The HTML calls do not take attachments.
{
    "DataAsBase64": "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz4K...",
    "Document": "CaseLetter2 - Online",
    "MetaFile": "CompanyLetters"
}

Answers

  • 200 with the file.
  • 204 when the data should not produce a document.
  • 406 when the data cannot be produced because logic is missing in the MetaFile.
  • 429 when you send too many requests at once. These calls are rate limited: pdf/create and pdf/simplex/create with XML data, all mfdx calls and dynamo/create with 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);
}