4D Write Pro – New image formats

Starting with 4D v19 R2, inline as well as anchored images inside 4D Write Pro documents will benefit from new formatting types.

We’ve also made it much easier to format the images used as background of documents, sections, paragraphs, etc.

Let’s find out more about these enhancements.

Formatting inline and anchored pictures

By default, an image is always formatted so that it completely fills the area defined by its frame. This is the “non-proportional” (Scaled to fit) mode, which constrains the image and may eventually distort it.

Other formatting modes are now possible thanks to the new wk image display mode attribute . As a 4D developer, the possible values of these modes are probably familiar to you. There are seven of them:

  • Scaled to fit (by default)
  • Truncated
  • Truncated centered
  • Proportional
  • Proportional centered
  • Replicated
  • Replicated centered


Each of these modes corresponds to a specific need. For example, the proportional mode (centered or not) lets you define any height and width for an image, keep it in its frame, and preserve its aspect ratio (the image will not be distorted).

This can be done using the document contextual menus, and by programming.


The image in the header of your document contains the logo of a company. It comes from a formula that returns an image. You don’t know the size of that image, but you want it to be 2 cm high and 2 cm wide without distorting it.



// get the image using its id ("logo")
$pictElem:=WP Get element by ID(WParea; "logo")
// apply the display mode and dimensions
 wk image display mode; wk proportional centered;\
 wk width; "2cm";\
 wk height; "2cm")


Formatting background pictures

All these types of formatting were already available for images used in the background of the document (or its sections, paragraphs, etc.). But to get the desired result, you had to change not just one, but up to six attributes.

Good news, now it’s a breeze thanks to a new attribute: wk background display mode. This attribute is an “abstract” attribute, which means it does not exist per se, but it will modify all the necessary attributes at once to set the display mode.


You have an image set as the background of a paragraph and the image must fit the size of the paragraph, whatever its width and height.



To do this, you could execute the following code:

WP SET ATTRIBUTES($paragraph;\
 wk background width; "100%";\
 wk background height; "100%";\
 wk background repeat; wk no repeat;\
 wk background origin; wk padding box;\
 wk background position horizontal; wk left;\
 wk background position vertical; wk top)

But from now on, all this can be written in one line for the same result!

WP SET ATTRIBUTES($paragraph; wk background display mode; wk scaled to fit)




The wk image display mode image attribute adds new possibilities for inline and anchored images, while wk background display mode simplifies the code writing for background formatting.

Now you can create documents that are more beautiful and more professional than ever before!

Roland Lannuzel
• Product Owner & 4D Expert •After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.