WP Insert picture
WP Insert picture ( targetObj ; picture ; mode {; rangeUpdate} ): Object
WP Insert picture ( targetObj ; pictureFileObj; mode {; rangeUpdate}): Object
Parámetros | Tipo | Descripción | |
---|---|---|---|
targetObj | Object | → | Rango o elemento o documento 4D Write Pro |
picture | Picture | → | Picture field or variable, or path to picture file on disk |
pictureFileObj | 4D.File | → | A File object representing a picture file. |
mode | Integer | → | Modo de inserción |
rangeUpdate | Integer | → | Range update mode |
Resultado | Object | ← | Object referencing the picture |
Descripción
El comando WP Insert picture inserta picture o una imagenFileObj en el targetObj especificado de acuerdo al mode de inserción pasado y los parámetros rangeUpdate, y devuelve una referencia al elemento de imagen. La imagen se insertará como un caracter en targetObj.
En targetObj, puede pasar:
- Un rango
- An element (table / row / paragraph / body / header / footer / inline picture / section / subsection)
- Un documento 4D Write Pro
For the second parameter, you can pass either:
- En picture:
- A picture field or variable
- A string containing a path to a picture file stored on disk, in the system syntax. If you use a string, you can pass either a full pathname, or a pathname relative to the database structure file. You can also pass a file name, in which case the file must be located next to the database structure file. You can also pass a file name, in which case the file must be located next to the database structure file.
- In pictureFileObj : a
File
object representing a picture file.
Todo formato imagen soportado por 4D puede ser usado. 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.
In the mode parameter, pass one of the following constants to indicate the insertion mode to be used on the picture in the document:
Constante | Tipo | Valor | Comentario |
---|---|---|---|
wk append | Integer | 2 | Insert contents at end of target |
wk prepend | Integer | 1 | Insert contents at beginning of target |
wk replace | Integer | 0 | Replace target contents |
If targetObj is a range, you can optionally use the rangeUpdate parameter to pass one of the following constants to specify whether or not the inserted picture is included in the resulting range:
Constante | Tipo | Valor | Comentario |
---|---|---|---|
wk exclude from range | Integer | 1 | Picture not included in the updated range |
wk include in range | Integer | 0 | Imagen incluida en el rango actualizado (por defecto) |
If you do not pass a rangeUpdate parameter, by default the inserted picture is included in the resulting range.
- If targetObj is not a range, rangeUpdate is ignored.
Ejemplo 1
In the following example, a user selects the picture they want to insert into the range object and will be warned if this picture could not be inserted:
var $wpRange : Object
$wpRange:=WP Get selection([EXAMPLES]wpDoc)
var $fail : Boolean
$fail:=False
//ask user to choose a picture on the disk that they want to insert
$imgRef:=Open document("")
//if user does not cancel
If(OK=1)
//if the file is a supported picture file
If(Is picture file(document))
// insert picture selected by user
WP Insert picture($wpRange;document;wk replace)
Else
$fail:=True
End if
Else
$fail:=True
End if
//if the insertion failed, alert the user
If($fail)
ALERT("Picture insertion failed")
End if
Ejemplo 2
You want to insert a picture in the body of the documment:
var $file : 4D.File
var $pictRef : Object
$file:=File("/RESOURCES/NovelCover1.jpg")
WParea:=WP New
$pictRef:=WP Insert picture(WParea; $file; wk replace)