MOO API /

Documentation

Side Data Object Model

Side Data models

The individual Pack user data elements on the Side instances are the building blocks of the actual customer content. They link up with a Template content definition in order to render. Note that you can have user data elements with linkId's that don't exist in the current template. For example you may have extra text lines on a business card that are not present now that the customer has requested a different template. If the customer switched back to the original template, the lines would still be valid.

Common properties

All data items MUST have the following properties set:

  • type - string - the type of data item (since JSON is untyped). MUST be one of "textData", "multiLineTextData", "imageData", "fixedImageData", "boxData". Any other value will result in outright rejection of the Pack.
  • linkId - string - the linkId of this data item to link up with the corresponding Template content element definition. Note that the type of the item MUST correspond with the type of the Template content element. It is NOT required that the linkId exist in the specified side.templateCode for the Side on which this data item exists.

TextData Object

The TextData object provides override information for an individual single line Template content element. Most templates will allow various items to be overridden, but some will enforce certain constraints in order to provide more certainty that the printed product will be as good as the customer expects it to be.

Parameters

  • type - string - MUST be textData
  • linkId - string - The linkId MUST be the linkId of one of the Text Items in the template chosen for side that this data object is defined in
  • text - string - The text content to be rendered. MUST be in UTF-8 encoding. If the template constrains the text as fixed, then supplying this will cause validation to fail.
  • font - Font - Overrides the Font specified on the template. See the Font for more information on the structure of the Font object. If the template constrains the font as fixed, then supplying this will cause validation to fail.
  • colour - Colour - Overrides the Colour specified on the template. See the Colour for more information on the structure of the Colour object. If the template constrains the colour as fixed, then supplying this will cause validation to fail.
  • pointSize - float - Overrides the Point size specified on the template. Note that this MUST be in the units specified by the template, which will almost always be millimeters. Use a conversion factor of 25.4 mm / 72 pt to change point sizes to millimeters. 7pt = 2.4694444 mm. If the template constrains the pointSize as fixed, then supplying this will cause validation to fail.
  • alignment - string - The alignment of the text within the text line. MUST be one of "left", "center", "right". If the template constrains the alignment as fixed, then supplying this will cause validation to fail.

Example TextData Object

"data":[
    {
        "type":"textData",
        "linkId":"back_line_1",
        "text":"API test: Name",
        "font":{
            "fontFamily":"helvetica",
            "bold":true,
            "italic":false
        },
        "colour":{
            "type":"RGB",
            "r": 255,
            "g": 0,
            "b": 0
        },
        "pointSize":2.82222222222,
        "alignment":"left"
    }
]

MultiLineTextData Object

The MultiLineTextData object provides override information for an individual multi-line text area Template content element. Most templates will allow various items to be overridden, but some will enforce certain constraints in order to provide more certainty that the printed product will be as good as the customer expects it to be. Note that we do NOT support embedded styling within a text blocks.

Parameters

  • type - string - MUST be multiLineTextData
  • linkId - string - The linkId MUST be the linkId of one of the Multi Line Text Items in the template chosen for side that this data object is defined in
  • text - string - The text content to be rendered. MUST be in UTF-8 encoding. If the template constrains the text as fixed, then supplying this will cause validation to fail. Forced line breaks should be supplied as a \n newline character.
  • font - Font - Overrides the Font specified on the template. See the Font for more information on the structure of the Font object. If the template constrains the font as fixed, then supplying this will cause validation to fail.
  • colour - Colour - Overrides the Colour specified on the template. See the Colour for more information on the structure of the Colour object. If the template constrains the colour as fixed, then supplying this will cause validation to fail.
  • pointSize - float - Overrides the Point size specified on the template. Note that this MUST be in the units specified by the template, which will almost always be millimeters. Use a conversion factor of 25.4 mm / 72 pt to change point sizes to millimeters. 7pt = 2.4694444 mm. If the template constrains the pointSize as fixed, then supplying this will cause validation to fail.
  • alignment - string - The alignment of the text within the text line. MUST be one of "left", "center", "right". If the template constrains the alignment as fixed, then supplying this will cause validation to fail.

Example MultLineTextData Object

"data":[
    {
        "type":"multiLineTextData",
        "linkId":"back_line_1",
        "text":"API test: Name",
        "font":{
            "fontFamily":"helvetica",
            "bold":true,
            "italic":false
        },
        "colour":{
            "type":"RGB",
            "r": 255,
            "g": 0,
            "b": 0
        },
        "pointSize":2.82222222222,
        "alignment":"left"
    }
]

ImageData Object

The ImageData object provides information about an image to be used for rendering into an image Template content element. NOTE - If you want transparent images, please use images embedded into PDFs but NOT PNG's (and especially not those with a 24-bit alpha channel), as the results of rendering these types of images are currently sub-optimal. We are working on this ... please bear with us.

Parameters

  • type - string - MUST be imageData
  • linkId - string - The linkId MUST be the linkId of one of the Image Items in the template chosen for side that this data object is defined in
  • imageBox - BoundingBox - The imageBox defines the position and rotation of the image within the area available. See the Image Positioning page for more information about how the renderer uses the imageBox data in conjunction with the Template ClippingBox to render an image.
  • resourceUri - string - A resource URI to the print resolution image to be rendered. See the Resource URI page for more information about resource URI structures. NOTE that if you wish to drop the customer into the MOO website flow to finish the print product, then the ImageBasket MUST be fully populated with details of all the images in use on the pack first.
  • imageStoreFileId - string - RESERVED - Can be left NULL, but should be preserved if a Pack already has this field set (it's an internal tracking field that will be set for some packs)
  • enhance - bool - Whether to run the image through the MOO Image Enhancement software before printing.

Example ImageData Object

"data":[
    {
         "type":"imageData",
         "linkId":"variable_image_front",
         "imageBox":{
             "center":{
                 "x":16,
                 "y":37
             },
             "width":55.4893617021,
             "height":74,
             "angle":0
         },
         "resourceUri":"filestore://image_original/7b83fe35-75ba-c0a802e8-4c754942-4de8.png",
         "imageStoreFileId":null,
         "enhance":false
    }, ...
]

FixedImageData Object

The FixedImageData object allows for the template to specify the size and position of an image to be printed on a Side, possibly allowing for the customer to choose which image is used.

Parameters

  • type - string - MUST be fixedImageData
  • linkId - string - The linkId MUST be the linkId of one of the Fixed Image Items in the template chosen for side that this data object is defined in
  • resourceUri - string - MUST be from the choice list provided by the template. If the template does not provide a choice, then supplying this will cause a validation error.

Example FixedImageData Object

"data":[
    {
        "type":"fixedImageData",
        "linkId":"background_box",
        "resourceUri":"filestore://image_original/77d14003-1894-558545ee-48e0f943-3b8a.pdf"
    }
]

BoxData Object

The BoxData object allows for customers to change the background colour of a Side of the printed product. NOTE that you should NOT attempt to colour match backgrounds of images with background colours of image elements in the user data, as I'm afraid the logic to work out the mapping from RGB -> CMYK will almost certainly produce a different colour for the background and image (even more so where it's a JPEG). Colour clashes will be much more evident on the printed product than they are on screen.

Parameters

  • type - string - MUST be boxData
  • linkId - string - The linkId MUST be the linkId of one of the Box Items in the template chosen for side that this data object is defined in
  • colour - Colour - Overrides the Colour for the box fill specified on the template. See the Colour for more information on the structure of the Colour object.

Example BoxData Object

"data":[
    {
        "type":"boxData",
        "linkId":"background_box",
        "colour":{
            "type":"RGB",
            "r": 0,
            "g": 0,
            "b": 0
        }
    }, ...
]

Appendix - JSON Pack Side Data Pseudo Schema

"textData" => array(
    "type" => "string",
    "linkId" => "string",
    "text" => "string",
    "font" => array(
        "fontFamily" => "string",
        "bold" => "boolean",
        "italic" => "boolean"
    ),
    "colour" => array(
        "type" => "string", /* RGB or CMYK */
        /* type == "RGB" */
        "r" => "integer", /* 0-255 */
        "g" => "integer", /* 0-255 */
        "b" => "integer", /* 0-255 */
        /* type == "CMYK" */
        "c" => "float", /* 0.0-100.0 */
        "m" => "float", /* 0.0-100.0 */
        "y" => "float", /* 0.0-100.0 */
        "k" => "float", /* 0.0-100.0 */
    ),
    "pointSize" => "float",
    "alignment" => "float"
),
"multiLineTextData" => array(
    "type" => "string",
    "linkId" => "string",
    "text" => "string",
    "font" => array(
        "fontFamily" => "string",
        "bold" => "boolean",
        "italic" => "boolean"
    ),
    "colour" => array(
        "type" => "string", /* RGB or CMYK */
        /* type == "RGB" */
        "r" => "integer", /* 0-255 */
        "g" => "integer", /* 0-255 */
        "b" => "integer", /* 0-255 */
        /* type == "CMYK" */
        "c" => "float", /* 0.0-100.0 */
        "m" => "float", /* 0.0-100.0 */
        "y" => "float", /* 0.0-100.0 */
        "k" => "float", /* 0.0-100.0 */
    ),
    "pointSize" => "float",
    "alignment" => "float"
),
"imageData" => array(
    "type" => "string",
    "linkId" => "string",
    "imageBox" => array(
        "center" => array(
            "x" => "float",
            "y" => "float"
        ),
        "width" => "float",
        "height" => "float",
        "angle" => "float"
    ),
    "resourceUri" => "string",
    "enhance" => "boolean"
),
"fixedImageData" => array(
    "type" => "string",
    "linkId" => "string",
    "resourceUri" => "string",
    "enhance" => "boolean"
),
"boxData" => array(
    "type" => "string",
    "linkId" => "string",
    "colour" => array(
        "type" => "string", /* RGB or CMYK */
        /* type == "RGB" */
        "r" => "integer", /* 0-255 */
        "g" => "integer", /* 0-255 */
        "b" => "integer", /* 0-255 */
        /* type == "CMYK" */
        "c" => "float", /* 0.0-100.0 */
        "m" => "float", /* 0.0-100.0 */
        "y" => "float", /* 0.0-100.0 */
        "k" => "float", /* 0.0-100.0 */
    )
)
  Oh hi, nice to see you! Fonts Terms & conditions Privacy policy © MOO Inc., 985 Waterman Avenue, East Providence, RI 02914, USA - Registered in the United States of America.