This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v20 R8
Accessing document contents by programming
|
Constant | Value | Comment |
wk end | end | (Read-only attribute)
Value type: Longint |
wk owner | owner | (Read-only attribute) Owner of the range/object/section/subsection (reference to the document for section/subsection). Value type: Object |
wk start | start | (Read-only attribute)
Value type: Longint |
wk type | type | (Read-only attribute) Type of 4D Write Pro object. Possible values:
For ranges of cells, columns and rows only:
For subsections only:
|
Note: Ranges of cells, columns and rows contain specific attributes (see paragraph below).
Several commands allow you to define document ranges:
You can get information about the position of a range in a document (page number, column number...) using the WP Get position command.
4D Write Pro tables are created and built programmatically by using the following commands:
(*) Columns have no equivalent in HTML. In 4D Write Pro, a column range is actually a range of cells.
The ranges of rows, columns and cells have specific, private attributes allowing to define them:
Constant | Value | Comment |
wk cell count | cellCount | Total number of cells in the row. Value type: Longint (value for wk type table row) |
wk column count | columnCount | (Available for tables, documents and sections) Number of columns. Value type: Longint
|
wk first column | firstColumn | (Read-only attribute) Number of the first table column included in the range. Value type: Longint |
wk first row | firstRow | (Read-only attribute) Number of the first table row included in the range. Value type: Longint |
wk header row count | headerRowCount | (Read/Write) Number of rows of the table with the attribute wk header set to True. Maximum value is 5. If you pass a value above 5, wk header is set to True for the first five rows only (see Repeated headers). |
wk row count | rowCount | (Read-only attribute) Total number of rows. Value type: Longint |
wk table | table | (Read-only attribute) The parent table. Value type: Object |
wk table ID | tableID | (Read-only attribute) ID of the parent table. Value type: String |
As detailed in the Handling headers, footers, and sections paragraph, 4D Write Pro documents can contain:
Sections and subsections are objects can be handled programmatically using the following commands:
Note also that specific headers and footers can be attached to sections or subsections, using the following commands:
Section and subsection objects support the following attributes:
4D Write Pro allows you to create and work with dynamic references to parts of your documents, called bookmarks. A bookmark is a named reference attached to a specific range in a 4D Write Pro document.
Bookmarks are dynamic, which means that if the user moves, adds or removes text belonging to the bookmark, the associated range will be updated automatically and the bookmark will continue to reference the same content within the document. For example:
A document can contain an unlimited number of bookmarks. Several bookmarks can reference the same range, and bookmark ranges can be interleaved. However, each bookmark name must be unique in the document. Bookmarks are not imported when using the WP INSERT DOCUMENT command (bookmarks in the destination document cannot be overwritten).
Once created, a bookmark is stored within the document. It is saved with the document, and can be handled by several different commands. It can also be used to reference parts of a template document. These parts can then be assembled automatically with data from the database to produce dynamic output documents such as invoices or catalogs.
Several commands allow you to create, remove, and use bookmarks:
The following commands can get or set any attributes of the document:
Attributes are detailed in the 4D Write Pro Attributes section.
This command allows you to get information about style support for a range:
4D Write Pro allows you to assign hyperlinks to any target object of your document, including ranges (text, picture, etc.), elements (table, body, footer, etc.), or the whole document. For example, you can set a URL hyperlink to a picture range; if the 4D Write Pro document is exported to HTML, users can click the picture to open a page at a specified address.
Hyperlinks can also be activated from within 4D Write Pro documents using the Ctrl+click (Windows) or Cmd+click (macOS) shortcut. In a non-enterable 4D Write Pro document, a link can be activated using a simple click.
4D Write Pro supports links of the following types:
Hyperlinks are managed through the following commands:
Note: Links are handled as attributes, thus they can be set or get using the WP SET ATTRIBUTES and WP GET ATTRIBUTES commands along with the wk link url constant. However, we recommended using WP SET LINK and WP Get links because they automatically encode/decode hyperlinks as URLs. When reading links using the WP GET ATTRIBUTES command, if the target object contains several links, the command returns the first link string.
For example, if you want to transform the text selected by the user into a URL link to a web site:
You can write:
$range:=WP Get selection(*;"WParea")
WP SET LINK($range;New object("url";"http://www.4d.com"))
To remove a link from a target object, you can write either:
WP RESET ATTRIBUTES($range;wk link url)
or
WP SET ATTRIBUTES($range;wk link url;"")
Note: If $range does not include the whole link, the link is truncated but not entirely removed.
A style sheet is an object of defined set of attribute settings used to control the appearance of your 4D Write Pro documents. These settings can be applied to paragraphs and characters, such as the font to display, as well as the font's size, color, and weight. Once a style sheet is defined, it is saved as an object in the 4D Write Pro document so it can easily be reused. Style sheets let you give your documents a distinctive and unique appearance, while saving you time and effort.
Default style
All 4D Write Pro documents have a default paragraph style sheet, "Normal". New style sheets (created with the WP New style sheet command) automatically inherit from the Normal style. Attributes modified by a style sheet effect only the paragraphs they are applied to, the rest of the document retains the default Normal settings. If a style sheet is removed, the modified attributes will revert to the Normal style.
The Normal style defines a default value for every style sheet attribute in a 4D Write Pro document and can be retrieved with the WP Get style sheet command. The Normal style sheet can be modified (but not renamed) with the WP SET ATTRIBUTES command. While style sheets created with the WP New style sheet command can be deleted with the WP DELETE STYLE SHEET command, the Normal style sheet can not be deleted.
Paragraph and character style sheet attributes
Style sheets allow you to define the attributes of entire paragraphs or specific characters:
Note that paragraph styles apply to whole paragraphs. To apply a style only to a specific part of a paragraph, you must use a character style sheet.
Style sheet precedence
Multiple paragraph and character style sheets can be combined within the same 4D Write Pro document. It's important to note style sheet precedence is determined by the order they are applied.
Applying style sheets
Style sheets are applied with the WP SET ATTRIBUTES command using the wk style sheet or wk new line style sheet constants (or using object notation). For more information, see 4D Write Pro Attributes.
Retrieving style sheets
The WP Get style sheets command lets you retrieve all style sheets in a document according to their specific type. The WP Get style sheet command lets you retrieve a single style sheet by its name.
Importing and exporting style sheets
Because style sheets are stored as objects, they can easily be imported into other 4D Write Pro documents or maintained when exported in multiple formats.
Style sheet attributes
The following paragraph and character style sheet attributes can be modified with the WP SET ATTRIBUTES and WP RESET ATTRIBUTES commands, or retrieved with the WP GET ATTRIBUTES command.
Note: Some attributes are linked together. Therefore when adding only one of these attributes, the other linked attributes will also be created with the default values. For linked attributes, the default value can be different than the value defined in the Normal style sheet. For example, if you define only a red left border, the other borders will be black (default value) even if the borders in the Normal style sheet were previously defined as purple.
Attributes | Paragraph | Character | Linked With |
wk avoid widows and orphans | X | ||
wk background clip | X | ||
wk background color | X | X | |
wk background height | X | wk background width | |
wk background image | X | ||
wk background image url | X | ||
wk background origin | X | ||
wk background position horizontal | X | wk background position vertical | |
wk background position vertical | X | wk background position horizontal | |
wk background repeat | X | ||
wk background width | X | wk background height | |
wk border color | X | wk border color bottom, wk border color left, wk border color right, wk border color top | |
wk border color bottom | X | wk border color, wk border color left, wk border color right, wk border color top | |
wk border color left | X | wk border color, wk border color bottom, wk border color right, wk border color top | |
wk border color right | X | wk border color, wk border color bottom, wk border color left, wk border color top | |
wk border color top | X | wk border color, wk border color bottom, wk border color left, wk border color right | |
wk border radius | X | ||
wk border style | X | wk border style bottom, wk border style left, wk border style right, wk border style top | |
wk border style bottom | X | wk border style, wk border style left, wk border style right, wk border style top | |
wk border style left | X | wk border style, wk border style bottom, wk border style right, wk border style top | |
wk border style right | X | wk border style, wk border style bottom, wk border style left, wk border style top | |
wk border style top | X | wk border style, wk border style, wk border style bottom, wk border style left | |
wk border width | X | wk border width bottom, wk border width left, wk border width right, wk border width top | |
wk border width bottom | X | wk border width, wk border width left, wk border width right, wk border width top | |
wk border width left | X | wk border width, wk border width bottom, wk border width right, wk border width top | |
wk border width right | X | wk border width, wk border width bottom, wk border width left, wk border width top | |
wk border width top | X | wk border width, wk border width bottom, wk border width left, wk border width right | |
wk direction | X | ||
wk font | X | X | wk font bold, wk font italic, wk font size |
wk font bold | X | X | wk font, wk font family, wk font italic, wk font size |
wk font family | X | X | wk font, wk font bold, wk font italic, wk font size |
wk font italic | X | X | wk font, wk font bold, wk font family, wk font size |
wk font size | X | X | wk font, wk font bold, wk font family, wk font italic |
wk line height | X | ||
wk list font | X | ||
wk list string format LTR | X | ||
wk list string format RTL | X | ||
wk list style image | X | ||
wk list style image height | X | ||
wk list style image url | X | ||
wk list style type | X | ||
wk margin | X | wk margin bottom, wk margin left, wk margin right, wk margin top | |
wk margin bottom | X | wk margin, wk margin left, wk margin right, wk margin top | |
wk margin left | X | wk margin, wk margin bottom, wk margin right, wk margin top | |
wk margin right | X | wk margin, wk margin bottom, wk margin left, wk margin top | |
wk margin top | X | wk margin, wk margin bottom, wk margin left, wk margin right | |
wk min height | X | ||
wk min width | X | ||
wk name | X | X | |
wk new line style sheet | X | ||
wk owner | X | X | |
wk padding | X | wk padding bottom, wk padding left, wk padding right, wk padding top | |
wk padding bottom | X | wk padding, wk padding left, wk padding right, wk padding top | |
wk padding box | X | ||
wk padding left | X | wk padding, wk padding bottom, wk padding right, wk padding top | |
wk padding right | X | wk padding, wk padding bottom, wk padding left, wk padding top | |
wk padding top | X | wk padding, wk padding bottom, wk padding left, wk padding right | |
_o_wk page break inside | X | ||
wk tab default | X | wk tabs, wk tab stop offsets, wk tab stop types, wk tab stop leadings | |
wk tabs | X | wk tab default, wk tab stop offsets, wk tab stop types, wk tab stop leadings | |
wk tab stop offsets | X | wk tabs, wk tab default, wk tab stop types, wk tab stop leadings | |
wk tab stop types | X | wk tabs, wk tab default, wk tab stop offsets, wk tab stop leadings | |
wk tab stop leadings | X | wk tabs, wk tab default, wk tab stop offsets, wk tab stop types | |
wk text align | X | ||
wk text color | X | X | |
wk text indent | X | ||
wk text linethrough color | X | X | |
wk text linethrough style | X | X | wk text underline style |
wk text shadow color | X | X | wk text shadow offset |
wk text shadow offset | X | X | wk text shadow color |
wk text transform | X | X | |
wk text underline color | X | X | |
wk text underline style | X | X | wk text linethrough style |
wk type | X (read only) | X (read only) | |
wk vertical align | X | X | |
wk width | X |
Product: 4D
Theme: 4D Write Pro Language
Modified: 4D v16
Modified: 4D v16 R4
Modified: 4D v16 R5
4D Write Pro Reference ( 4D v20 R8)