Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

...

WordTemplate can insert certain types of documents into docx files by adding the "document(format)" modifier to the merge field, where format is one of the following:

  • rtf - The binary data in the data source will be inserted as an rtf document, e.g. «Product.Doc(document(rtf))».
  • html - The binary data in the data source will be inserted as an html document, e.g. «Product.Webpage(document(html))».
  • docx (Introduced in 8.5) - The binary data in the data source will be inserted as an docx document, e.g. «Product.Doc(document(docx))»

To add the modifier:

  1. Create or open a WordWriter template (for instructions, see Creating a WordWriter Template).
  2. Add the "document(rtf)" modifier , "document(html)" or "document(docx)" modifier in parentheses to the merge field in which you want to insert the rtf document. For example, change «Product.Doc» to «Product.Doc(document(rtf))»

Binding the data:
The data that corresponds to the merge field with the document modifier must be a byte array.

Paragraphs

When inserting an rtf embedded document, the document must go at the same level as the paragraphs, this means that if the merge field is in the middle of a paragraph:

Some Text Before «Product.Doc(document(rtf))» Some text after

It will become:

Some Text Before
My sweet rtf document
has some content
Some text after

As a special case, if you don't have any content on either side:

«Product.Doc(document(rtf))»

It will become:

My sweet rtf document
has some content

to align the template file with the output, document fields should be put in their own paragraph:
Image Added
Will become:
Image Added

If there is content on both sides, paragraph breaks will be inserted on either side of the document:
Image Added
Will become:
Image Added

Having only text before or only text after, will result in a blank paragraph on the other side, such as:

...

Image Added

Will become:

Some Text Before
My sweet rtf document
has some content
{quote}

Image Added

Formatting

Rtf and html documents maintain their own formatting, so if there is some bold text, or a right-aligned paragraph in the

...

document it will maintain that formatting. This includes the default font for the document, which may not match the default font of the template.

Restrictions

...

Like regular merge fields document fields can be in an if field's optional text to display, but, because WordTemplate does not parse the contents of the

...

document,

...

document fields in the comparison portion of if fields

...

are not supported, when UpdateIfFields is set to true.
Because inserting an

...

embedded document is not the same as inserting a character run, some formatting and document structures do not support

...

document fields:

...

  • The displayed output of another field

...

  • , however if it is in the field codes it will be handled like other fields.
  • Hyperlinks

...

  • Phonetic guides
  • Structured document tags

...

  • (these are the items created when quick parts are inserted, and have the little tab, e.g. "Title").

...