Page tree

Versions Compared

Key

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

Tabled of Contents

Table of Contents
Excerpt

WordWriter allows you to insert jpg, gif, bmp, and png images in merge fields. You can insert images repeat block and main document merge fields. There are two ways to insert an image into a merge field:

Using a Placeholder

To insert an image in a merge field using a placeholder:

...

  1. Right-click the image and select Format Picture...
  2. Select the Size tab.
  3. Check or uncheck Lock aspect ratio.
  4. Check or uncheck Relative to original picture size .

Relative \
to original \
picture size

Lock aspect ratio

Meaning

false

false

The image will maintain its natural size and aspect ratio.

true

false

The image will be scaled to fit into the placeholder image but keep its natural aspect ratio.

false

true

The image will be scaled to fit into the placeholder image but keep its natural aspect ratio. The image will not be enlarged if it is smaller than the placeholder image.

true

true

The image will be scaled to fit into the placeholder image and its aspect ratio.

...

Code Block
titleOfficeWriter v8.6.1 - Inserting an Image from a file
languagecsharp

WordTemplate wt = new WordTemplate();

//image from a file path
string newImage = @"C:\image.png";

//create a string array of field names.
//the field names must be the same as the merge field
//names in the template.
string[] arrfields = {"Product.Image(image1,600,600))"};

//create an object array of values
//ordinal numbers match those of the fields array
object[] arrvalues = {newImage};

//set the data source
wt.SetDataSource(arrvalues, arrfields, "ImageSource");

//process the data
wt.Process();

...

Code Block
titleInserting an Image from a byte array
languagecsharp

//create byte array from image
byte[] imgArray = File.ReadAllBytes(@"C:\image.png");

//create an object array of values
//ordinal numbers match those of the fields array
object[] arrvalues = {imgArray};

//create a string array of field names.
//the field names must be the same as the merge field
//names in the template.
string[] arrfields = {"Product.Image(image1,600,600))"};

//set the data source
wt.SetDataSource(arrvalues, arrfields, "ImageSource");

wt.Process();

...