Component: RTF Document

 Show all Hide all

Creates an RTF document by inserting database content into a RTF template.

Component mode: Standard

Supported modes: Standard | Label

File mode: Download

The user downloads the file.
Supported modes: Download | Save | Save and download | Batch

Tags in the template

The RTF template can contain the following tags:

<#XXX#>
Normal tag that is replaced by the value in the column with the same name, i.e. XXX. Values such as dates and decimals should be formatted in the procedure and returned as varchars for consistent formatting. Tags can also contain special data like images (see further below).

All values are treated as RTF literals. That means that you can emit, for example, a \page command directly into the document. It also means that you need to use the SoftadminUtil.RTF_Escape function if you need to emit strings containing characters like '{', '}' or ''.

<#$$XXX#>...</#$$XXX#>
Section that surrounds a normal tag. If the value in the column XXX is NULL or missing then the entire section is skipped from the final document.

<##YYY##>...</##YYY##>
Container that is repeated 0-n times depending on the resultset. Each normal tag within the container corresponds to a column in a resultset.

<$$##YYY##>...</$$##YYY##>
Section that surrounds a container (with the same name). If zero rows are returned from the container SQL-statement, then the entire section is skipped from the final document.

Images

For any normal tag where the database returns varbinary data, the data will be assumed to be either a PNG or JPG image and inserted into the document as such. The document will use the image's original resolution when printed.

QR Codes

For any normal tag where the database returns XML data with the root element QrCode a QR Code will be rendered and inserted into the document.

<QrCode cm="3.14">MyQrCode</QrCode>

The element accepts a single (optional) attribute, cm which specifies how large the code should be in centimeters. Do note that this size includes the mandatory quiet zone surrounding the QR code.

Component settings

Clean RTF Template
If on, tags are cleaned, container consistency is checked and corrected and spaces may be inserted between rtf control words and tags if neccessary to keep them separated after the tag is replaced with contents.
Process HTML
When activated supplied data is processed and HTML-tags for basic formatting are translated to corresponding RTF-formatting.

The affected HTML-tags are: <b> <i> <u> <strong> <em> <strike> <br> <tab> <s> <del>

SQL

SQL Call: Retrieve rtf template (mandatory)

Sql to retrieve RTF template from database.
Supports custom errors: No
May modify database: No

Parameters:

@template mandatory bit
Set to '1' by Softadmin® when the component asks for an rtf template.

Resultset: Rtf template

Repeat mode: repeated exactly once
Row count: zero or more rows

Columns:

xxx mandatory binary
Rtf template
xxxfilename optional string
Filename

SQL Call: Retrieve document data (mandatory)

SQL to retrieve information to fill the RTF template, this SQL is called first once, without the @container parameter set, then once for each container-tag.
Supports custom errors: No
May modify database: No

Parameters:

@<DocumentId> optional string
Used in batch mode. This parameter will have the same name as the first column in the batch documents result set of the Retrieve rtf template call, and contains the id value of the document.
@container optional string
Used if RTF template contains a container-tag (<##XXX##>...). The container tag is then repeated as many times as there are rows in the resultset.
@id optional string
Used if RTF template contains a container-tag within another container-tag (<##XXX##>..<##YYY##>....). The 'id' value is the first column in the outer resultset (in this case, the resultset generated by the <##XXX##>-tag).

Resultset: Data to fill document

Resultset that contains information to fill the RTF template with, each column name corresponds to a tag in the template (<#XXX#>). At least one row must be returned when @container is not set.

Images:
If the column is a varbinary column it is assumed to be a picture and is inserted as a picture in the document. Note that pictures in rtf documents are very large and it is therefore recommended that this feature is used with moderation.

QR Codes:
If the column contains the XML <QrCode cm="xxx">data</QrCode> then a QR code with the given data and size is inserted. Do note that the size includes the quiet zone around the QR code.
Repeat mode: repeated exactly once
Row count: zero or more rows

Columns:

xxx optional string
Replaces the tag <#xxx#>.

SQL Call: Forward to next menu item

You do not need to implement this call. It is only made if the procedure has a @Forward parameter.
Supports custom errors: No
May modify database: No

Parameters:

@forward optional bit
Set to '1' by Softadmin® when the component wants to know where to forward to.

Resultset: Forwarding definitions

Repeat mode:
Row count:

Columns:

<querystring_variable> optional string
Any column with no other specific meaning will pe passed along on the querystring to the menuitem you are forwarding to.
admin_cancelcidstepsback optional int
Number of steps in the page history to jump back if the user clicks OK in an ADMIN_MESSAGE dialog or Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelcidstepsback specified in the query string.
admin_cancelmenuitemid optional int
Id of the menuitem to execute if the user clicks OK in an ADMIN_MESSAGE dialog or Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
admin_cidstepsback optional int
Number of steps in the page history to jump back after execution (the default being one step back). This value overrides any destination specified by the query string.
admin_force optional string
Prompts the user with the specified text and the user may answer OK or cancel. If the user chooses OK the sql call will be rerun with the parameter @force set to 1.
admin_forward optional string
Displays a user friendly message and then forwards to the next menu item.
admin_forwardmenugroupid optional int
Id of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
admin_forwardmenuitemid optional int
Id of the menuitem to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
admin_message optional string
Displays a user friendly message to the user.
admin_pastehtmlfrompopup optional string
Pastes HTML. See admin_setfieldvaluefrompopup
admin_setfieldvaluefrompopup optional string
Sets the value of field specified in the menuitempopup call. Only select this column if menuitem is opened in popup.
Cache optional string
Cache key to be cleared. Supports wildcards.
CacheUserId optional string
Either a user id or '%'.

Clears all caches (e.g. access permissions) related to the specified user id.

Use '%' to clear caches for all users.
cancelbuttontext optional string
Changes the text of the Cancel button when used with ADMIN_Force.
okbuttontext optional string
Changes the text of the OK button when used with ADMIN_Message, ADMIN_Force, or ADMIN_Forward.

SQL Call: Validate parameters

Allows you to validate the parameters supplied by the user before any other SQL is run in the component. This call is only made if the component has visible parameters, the SQL is a stored procedure, and 'Validate parameters' is checked.
Supports custom errors: No
May modify database: No

Parameters:

@force optional bit
@validateparams mandatory bit
This parameter is set to 1 by Softadmin® when this call is made.

Custom access control and logging

SQL Call: Custom access control and logging

Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.

Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.

The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.

If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.
Supports custom errors: No
May modify database: Yes

Resultset: Access permissions

Return whether the user is allowed to visit the menu item with the current parameters.
Repeat mode: repeated exactly once
Row count: exactly one row

Columns:

GrantAccess mandatory bit
1 if the user is allowed to view the menu item, 0 if the user should not be allowed to view the menu item.

If 0 then an error will be logged as the user should not have been able to reach the menu item with the given parameters in the first place.

Best practice

Create template

Keep it simple, if the needed features are supported, create/save the template in WordPad instead of Word to get a less bloated template. This makes the documents smaller, faster to generate and less prone to errors.

Tables

When creating tables with a container tag the start container should be put in column 1 of the table, and the end container tag should be put after the table.

This should result in this order of data in the rtf file:
\trowd
\pard\intbl <##Container##>\cell\row
\pard </##Container##>