Advanced text editing

30/05/2010

By default web-to-print text fields only replace the text with user input. ZetaPrints web-to-print may change the appearance of the text automatically (wrapping, font resizing). This post explains how to add field manipulation metadata for user-defined editing, such text color, shift, etc.

Web-to-print metadata fields

Web-to-print text fields always begin with _ (underscore) followed by the field name, e.g. _Name or _Last name.

Metadata fields have the same name as the field they correspond to with an added * at the begging:

Example_Name (text field name), *_Name (metadata field name)

The fields should be sent in POST part of the request. Only one optional metadata field per text field is expected.

Understanding of shapes coordinates system and shape coordinates for editing is required before proceeding to the rest of the post.

Metadata parameters

Parameters are name value pairs separated by ; (semicolon). E.g. sh-x=0.3;sh-y=0.75;col-o=#aabbcc

Shift

Parameter names: sh-x, sh-y

Allowed values: -10.0 < value < 10.0, decimal, relative to the page size.

The value is the ratio of the shift to the page size as specified in the template details XML. Positive values – shift up and right, negative – shift down, left. Zero – no shift.

Invalid values are ignored.

Use shift params if you want a shape to be shifted exactly without altering the size at all for consistency.

Examples:

  • sh-x=0.3;sh-y=0.75 – shifts by 30% to the right and 75% down
  • sh-x=-0.5;sh-y=-0.2 – shifts by the 1/2 page width to the left and 1/5 page height up

Size

Parameter names: sz-x, sz-y

Allowed values: 0 < value < 10.0, decimal.

The value is the ratio of the new size to the size of the original placeholder shape as specified in the template details XML.

  • 0 < value < 1 – decrease size by value
  • 1 < value < 10 – increase size by value
  • value = 1 – no change

Invalid values are ignored.

Examples:

sz-x=0.3;sz-y=0.75 – decrease width to 30%, height to 75%

sz-x=1.1;sz-y=0.2 – increase width to 110%, decrease height to 20%

Color

Parameter names:

  • col-f – fill color
  • col-o – outline color

Allowed values: #RRGGBB

Invalid values are ignored. You can specify either or both at the same time.

Example:

col-f=#aabbcc;col-o=#001237 – specifies RGB values for fill and outline colors

New coordinates

Shift and resize can be combined into a single set of new shape coordinates: x1, y1, x2, y2.

  • x1, y1 – top left corner
  • x2, y2 -bottom right corner

The coordinates are expressed in the same relative units the original shape coordinates were expressed. All four parameters must have valid values. Shift and resize parameters are ignored if the new coordinates are provided. Use these params if the user performed a free-form shift / resize operation.

Parameter processing

Web-to-print text field processing is a sequence of steps on ZetaPrints side:

  1. replace text
  2. recalculate alignment, rotation and other properties to match the placeholder
  3. apply color parameters from the metadata
  4. apply new coordinates (exit if successful)
  5. apply shift from the metadata
  6. apply resizing paramas from the metadata

If is better to combine shift and resize into new coordinates.

See also: