This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19
WP EXPORT VARIABLE
|
WP EXPORT VARIABLE ( wpDoc ; destination ; format {; option} ) | ||||||||
Parameter | Type | Description | ||||||
wpDoc | Object |
![]() |
4D Write Pro variable | |||||
destination | Text variable, BLOB variable |
![]() |
Variable to receive exported contents | |||||
format | Longint |
![]() |
Variable output format | |||||
option | Object, Longint |
![]() |
Export options | |||||
The WP EXPORT VARIABLE command exports the wpDoc 4D Write Pro object to the 4D destination variable in the specified format.
In wpDoc, pass the 4D Write Pro object that you want to export.
In destination, pass the variable that you want to fill with the exported 4D Write Pro object. The type of this variable depends on the export format specified in the format parameter:
In the format parameter, pass a constant from the 4D Write Pro Constants theme to set the export format you want to use. Each format is related to a specific use. The following formats are supported:
Constant | Type | Value | Comment |
wk 4wp | Longint | 4 | The 4D Write Pro document is saved in a native archive format (zipped HTML and images saved in a separate folder). 4D specific tags are included and 4D expressions are not computed. This format is particularly suitable for saving and archiving 4D Write Pro documents on disk without any loss. |
wk docx | Longint | 7 | .docx extension. 4D Write Pro document is saved in Microsoft Word format. Certified support for Microsoft Word 2010 and newer. The document parts exported are:
|
wk mime html | Longint | 1 | 4D Write Pro document is saved as standard MIME HTML with HTML documents and images embedded as MIME parts (encoded in base64). Expressions are computed and 4D specific tags are removed. This format is particularly suitable for sending HTML emails with the SMTP_QuickSend command. |
wk pdf | Longint | 5 | .pdf extension. 4D Write Pro document is saved in PDF format, based on Page view mode.
The following metadata is exported in a PDF document:
Notes:
|
wk web page html 4D | Longint | 3 | 4D Write Pro document is saved as HTML and includes 4D specific tags; each expression is inserted as a non-breaking space. Since this format is lossless, it is appropriate for storing purposes in a text field. |
Notes:
Pass an object in option containing the values to define the properties of the exported document. The following properties are available:
Constant | Value | Comment |
wk CID host domain name | cidHostDomain | CID host domain name: host domain that will be added to generated CID URLs including an '@' as separator. Available only when the wk mime html format is used. |
wk HTML pretty print | htmlPrettyPrint | HTML code is formatted to be easier to read. |
wk max picture DPI | maxPictureDPI | Used for resampling (reducing) images to preferred resolution. For SVG images in Windows, used for rasterization. Default values:
Maximum possible value: 1440 |
wk optimized for | optimizedFor | Defines how an exported document is optimized based on its intended medium. Possible values:
|
wk recompute formulas | recomputeFormulas | Defines if formulas must be recomputed when exported. Possible values:
|
wk visible background | visibleBackground | Displays both background images and background color (visible effect in Page or Embedded view mode only). Possible values: True/False |
wk visible footers | visibleFooters | Displays or exports the footers (for display, visible effect in Page view mode only). Possible values: True/False |
wk visible headers | visibleHeaders | Displays or exports the headers (for display, visible effect in Page view mode only). Possible values: True/False |
wk visible references | visibleReferences | Displays or exports all 4D expressions inserted in the document as references. Possible values: True/False |
The following table indicates the option available per export format:
wk 4wp | wk docx | wk mime html | wk pdf | wk web page html 4D | |
wk CID host domain name | - | - | ![]() | - | - |
wk HTML pretty print | ![]() | - | ![]() | ![]() | ![]() |
wk max picture DPI | - | always 300 | ![]() | ![]() | - |
wk optimized for | - | always wk print | ![]() | always wk print | - |
wk recompute formulas | - | ![]() | ![]() | ![]() | - |
wk visible background | - | always true | always true | ![]() | - |
wk visible footers | - | always true | always false | ![]() | - |
wk visible headers | - | always true | always false | ![]() | - |
wk visible references | - | - | - | ![]() | - |
Compatibility Note: Passing a longint value in option is supported for compatibility reasons, but it is recommended to use an object parameter.
You want to export the contents of the myArea 4D Write Pro object in MIME format and add "gmail.com" as the host domain:
var $option;$export : Object
$option[wk CID host domain name]:="gmail.com"
WP EXPORT VARIABLE(myArea;$export;wk mime html;$option)
You want to send an email containing styled text, 4D references and images. You can use a 4D Write Pro area exported in MIME format and sent using SMTP:
// create the transporter
$server:=New object
$server.host:="smtp.gmail.com"
$server.port:=465
$server.user:="4D@gmail.com"
$server.password:="XXXX"
$transporter:=SMTP New transporter($server)
WP EXPORT VARIABLE(WParea;$mime;wk mime html)
$mailTmp:=MAIL Convert from MIME($mime)
// add pictures (if any)
If($mailTmp.attachments#Null)
$email.attachments:=$mailTmp.attachments
End if
$email.bodyStructure:=$mailTmp.bodyStructure
$email.bodyValues:=$mailTmp.bodyValues
$status:=$transporter.send($email)
If(Not($status.success))
ALERT("An error occurred: "+$status.statusText)
End if
Product: 4D
Theme: 4D Write Pro Language
Number:
1319
Created: 4D v14 R5
Modified: 4D v15 R2
Modified: 4D v17 R4
4D Write Pro Reference ( 4D v19)