4D Blog

Home Product 4D Write Pro – New image formats

4D Write Pro – New image formats

July 19, 2021

Product

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.

Example

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.

blank

 

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

blank

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.

Example

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.

 

blank

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)

blank

 

Conclusion

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!

Discuss

Tags 4D Write Pro, Pictures, v19 R2, v20, Word processor

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Roland Lannuzel
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.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy