This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
Handling pictures
|
Constant | Comment |
wk proportional | When used as value of wk image display mode, the image is aligned at the top left of the content box, not replicated, scaled to fit the content box, and it keeps its aspect ratio.
When used as value of wk background display mode, presets the following attributes:
|
wk proportional centered | When used as value of wk image display mode, the image is centered in the content box, not replicated, scaled to fit the content box and it keeps its aspect ratio.
When used as value of wk background display mode, presets the following attributes:
|
wk replicated | When used as value of wk image display mode, the image is aligned at the top left of the content box, replicated, and keeps its original size.
When used as value of wk background display mode, presets the following attributes:
|
wk replicated centered | When used as value of wk image display mode, the image is centered in the content box, replicated, and keeps its original size.
When used as value of wk background display mode, presets the following attributes:
|
wk scaled to fit | When used as value of wk image display mode, the image is scaled to fit the content box and is not replicated.
When used as value of wk background display mode, modifies the following attributes:
|
wk truncated | When used as value of wk image display mode, the image is aligned at the top left of the content box, not replicated, and it keeps its original size.
When used as value of wk background display mode, presets the following attributes:
|
wk truncated centered | When used as value of wk image display mode, the image is centered in the content box, not replicated, and it keeps its original size.
When used as value of wk background display mode, presets the following attributes:
|
Adding pictures to a 4D Write Pro document can be accomplished in multiple ways and depend on your needs:
The way you add a picture determines the layer it is positioned in, as illustrated in the diagram below:
Anchored pictures are added with an absolute position, in front of/behind text, as well as anchored to the page or specific parts of a document (i.e., header, footer, sections). Setting an absolute position for a picture is accomplished with the WP Add picture and WP SET ATTRIBUTES commands.
Anchored picture positions can be modified with the following specific attributes and/or standard actions:
Property (constant) | Standard action |
wk anchor layout | anchorLayout |
wk anchor horizontal offset | |
wk anchor horizontal align | anchorHorizontalAlign |
wk anchor vertical offset | |
wk anchor vertical align | anchorVerticalAlign |
wk anchor origin | anchorOrigin |
wk anchor page | anchorPage |
wk anchor section | anchorSection |
moveToBack | |
moveToFront |
Anchored pictures support automatic text wrapping when anchored to a document with options like on the left, right, largest side, above and below, or all around provided through the property wk anchor layout or the standard action anchorLayout. Check this blog post for more details.
Pictures with text wrapping anchored to the body of the page do not affect the header or the footer (the picture is displayed in front of the header or the footer); on the contrary, pictures anchored to the header and footer affect the body of the page if they overlap it.
Note: If you want to anchor a picture with text wrapping to the header or footer, you must also set the vertical alignment of the picture to the top.
All anchored pictures are displayed in the Page view mode only. They're not displayed if:
You can insert 4D expressions that return pictures in your 4D Write Pro areas. Expressions can be variables, fields, project methods, formulas, object attributes or collection elements.
You can see an expression's reference in the picture tip(*):
(*)As there is no text associated with an anchored image, its expression reference cannot be displayed.
All image attributes can be applied to picture expressions (wk image and wk image url attributes can only be read). Note however, that since pictures have specific attributes, 4D Write Pro must evaluate the expression at least once to detect that its result is a picture and handle it as a picture expression. It means that when a picture expression is inserted with WP INSERT FORMULA, WP COMPUTE FORMULAS must be called before setting any picture attributes.
Note: As with other expressions, picture expressions are also impacted by the WP COMPUTE FORMULAS and WP FREEZE FORMULAS commands.
Anchored picture expressions are added with the WP Add picture command (without the second parameter), followed by a call to the WP SET ATTRIBUTES command with the wk image formula selector.
Example:
obImage:=WP Add picture(myDoc)
WP SET ATTRIBUTES(obImage;wk image formula;Formula(m_buildPict))
You can also insert picture expressions using WP SET ATTRIBUTES and wk image formula on existing anchored pictures.
Compatibility Note: wk image expression can still be used to define picture expressions through text. However, it is recommended to use wk image formula and objects.
Calling the WP RESET ATTRIBUTES command with wk image formula is similar to calling WP FREEZE FORMULAS (on the entire document) in that the expression is cleared from the image attribute. However WP FREEZE FORMULAS computes the expression before clearing, whereas WP RESET ATTRIBUTES does not. If an expression has never been computed, the default black frame image will be displayed.
Inline picture expressions are added with the WP INSERT FORMULA command.
Examples:
//Insert a picture variable
WP INSERT FORMULA(wpRange;Formula($vpict);wk prepend)
//Insert a field
WP INSERT FORMULA(wpRange;Formula([DOC]SamplePict);wk prepend)
//Insert a 4D method
WP INSERT FORMULA(wpRange;Formula(M_ComputeChart);wk prepend)
If an image is empty (e.g. it could not be loaded, or it results from an expression that could not be computed, or it uses an unsupported picture format), by default 4D Write Pro displays a black frame rectangle:
You can remove these black rectangles from the current view using:
You can also use the wk visible empty images selector with the WP EXPORT DOCUMENT and WP EXPORT VARIABLE commands to remove the black rectangles from exported contents.
Note that when this option is set, missing image elements will not be displayed at all even if they have borders, width, height, or background; this may impact the page layout for inline images.
All pictures have properties (attributes) such as height, width, borders, display mode, etc., that can be get or set via the 4D Write Pro language (WP GET ATTRIBUTES and WP SET ATTRIBUTES) or standard actions.
You can work with picture references (picture variables, fields, expressions) or picture URLs (text representing a local or network address of the picture).
Two sets of attributes allow you to define if you want to set or get picture reference or a picture URL:
Example:
$range:=WP Get selection(WPArea) //get the picture selected by user
$range:=WP Picture range($range) //create a range
$url:="http://doc.4d.com/image/logo/poweredby4D_web.png"
WP SET ATTRIBUTES($range;wk image;$url) //set an image reference from a URL
//get the image
C_PICTURE(vPictureGet)
WP GET ATTRIBUTES($range;wk image;vPictureGet) //vPictureGet contains an image
C_TEXT(vPictureURLGet)
WP GET ATTRIBUTES($range;wk image url;vPictureURLGet) //vPictureURLGet=$url
The following commands can be used to return pictures:
You can remove inline and anchored pictures with:
Pictures can be manipulated via the mouse or the keyboard. Available actions include:
Product: 4D
Theme: Handling pictures
Modified: 4D v16 R6
Modified: 4D v18 R2
Modified: 4D v20 R5
4D Write Pro Reference ( 4D v20 R7)