This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R7
WP Add picture
|
WP Add picture ( wpDoc {; picture} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
wpDoc | Object |
![]() |
4D Write Pro document | |||||
picture | Picture, Text |
![]() |
Picture or Picture path | |||||
Function result | Object |
![]() |
Object referencing the picture | |||||
The WP Add picture command anchors picture at a fixed location within the wpDoc and returns its reference. The returned reference can then be passed to the WP SET ATTRIBUTES command to move picture to any location in wpDoc (page, section, header, footer, etc.) with a defined layer, size, etc.
In wpDoc, pass the name of a 4D Write Pro document object.
In the optional picture parameter, you can pass:
Note: Any picture format supported by 4D can be used (see the Pictures section). You can get the list of available picture formats using the PICTURE CODEC LIST command. If the picture encapsulates several formats (codecs), 4D Write Pro only keeps one format for display and one format for printing (if different) in the document; the "best" formats are automatically selected.
By default, the added picture is:
The location, layer (inline, in front/behind text), visibility, and any properties of picture can be modified using the WP SET ATTRIBUTES command, or via standard actions (see Using 4D Write Pro standard actions).
Note: The WP Selection range command returns a picture reference object if a an anchored picture is selected and a range object if an inline picture is selected. You can check if a selected object is a picture object with the wk type attribute. If the value = 2, then it is a picture object, otherwise it is a range object (value = 0).
You want to add a picture with default settings using a filepath.
C_OBJECT($obPict)
$obPict:=WP Add picture(myDoc;"C:\\Users\\John.Doe\\Pictures\\Sunrise.jpg")
The result is:
You want to add a resized picture, centered and anchored to the header:
C_OBJECT($obImage)
$obImage:=WP Add picture(myDoc;"C:\\Users\\John.Doe\\Pictures\\Saved Pictures\\Sunrise.jpg")
WP SET ATTRIBUTES($obImage;wk anchor origin;wk header box)
WP SET ATTRIBUTES($obImage;wk anchor horizontal align;wk center)
WP SET ATTRIBUTES($obImage;wk anchor vertical align;wk center)
WP SET ATTRIBUTES($obImage;wk width;"650px";wk height;"120px")
The result is:
You want to use a field expression to add an anchored image to a document displaying some text from the database:
QUERY([Flowers];[Flowers]Common_Name="tulip")
WP SET TEXT(myDoc;[Flowers]Description;wk append) //insert text
C_OBJECT($obImage)
$obImage:=WP Add picture(myDoc)
WP SET ATTRIBUTES($obImage;wk image formula;Formula([Flowers]Image))
Download HDI database
Handling pictures
WP DELETE PICTURE
WP Picture range
Product: 4D
Theme: 4D Write Pro Language
Number:
1536
Created: 4D v16 R6
4D Write Pro Reference ( 4D v20 R7)