Text Templates

Start page  Previous page  Next page

 

Normally a Notes RichText field or an entire Notes document is used to define the content of a PDF file, whether for the main text or the headers and footers. Sometimes, such as for titles, it may be necessary to use the content from an unformatted field (e.g. TEXT) or a constant in the PDF. In this case there arises the problem of there being no formatting available for such a text. This is why n2pdf allows text templates to be defined.

 

Text templates enable you to give the text a distinct layout under one name. You can set such properties as the font size,  color or style or even the line spacing and tabs for text template. All the settings are administered internally using a freely assignable name, which is later used to select that particular template. Then when you want to insert a plain text into the PDF, you simply select a text template and insert the text. Selecting a text template before adding the text ensures that the text is inserted with the formatting of the chosen text template.

 

In addition to being able to configure freely definable text templates (each having its own name), n2pdf also recognizes a number of internal text templates that are earmarked for specific areas of the PDF. These text templates have permanently assigned names and are already configured with default values. Such text templates require no configuration and may be selected and used immediately. The predefined templates (the constants for programming in brackets) are the:

 

Table of Contents (for all levels)

(N2PDFVALUE_TOC_PARAGRAPH_NAME = "_TOC")

 

Table of Contents (individually for each level (1-10))

(N2PDFVALUE_TOC_LEVEL1_PARAGRAPH_NAME = "_TOC_LEVEL1"

N2PDFVALUE_TOC_LEVEL2_PARAGRAPH_NAME = "_TOC_LEVEL2"

...

...

N2PDFVALUE_TOC_LEVEL10_PARAGRAPH_NAME = "_TOC_LEVEL10")

 

The header for the Table of Contents

(N2PDFVALUE_TOC_HEADER_PARAGRAPH_NAME = "_TOC_HEADER")

 

The footer for the Table of Contents

(N2PDFVALUE_TOC_FOOTER_PARAGRAPH_NAME = "_TOC_FOOTER")

 

Global font replacement

(N2PDFVALUE_GLOBAL_PARAGRAPH_NAME = "_GLOBAL")

 

Hyperlink design

(N2PDFVALUE_HYPERLINK_PARAGRAPH_NAME = "_HYPERLINK")

 

Default text template

(N2PDFVALUE_DEFAULT_PARAGRAPH_NAME = "_DEFAULT")

 

The creation of user defined jump links

(N2PDFVALUE_JUMP_PARAGRAPH_NAME = "_JUMP")

 

The design of file links

(N2PDFVALUE_FILELINK_PARAGRAPH_NAME = "_FILELINK")

 

The design of e-mail addresses

(N2PDFVALUE_EMAILLINK_PARAGRAPH_NAME = "_EMAILLINK")

 

The design of footnotes

(N2PDFVALUE_FOOTNOTE_PARAGRAPH_NAME = "_FOOTNOTE")

 

Among these predefined text templates is also a default text template, which must always be used to insert a text when you have not selected one of your own text templates. This gives you the choice of completely defining a text template of your own or simply modifying the existing default text template.

 

Not all values have to be set when creating a text template. You need only set those you want to be different from the values that are set automatically. These are the predefined values you will encounter when creating a new text template:

 

Font type

Arial

Font size

10

Font color

Black

Bold

Off

Italic

Off

Underlined

Off

Superscript

Off

Subscript

Off

Strikethrough

Off

Paragraph background color

White

Background color

White

Alignment

Left

Line spacing

Single

Tabs

None

 

 

The entire process of defining the text templates and selecting from among them is handled by the function N2PDFSetOption. With this command, and its options and settings for the feature, you can configure new text templates and set their values accordingly. You can even change the settings for the predefined text templates using this function.

 

Example for creating your own "HEADLINE" text template with a font of type "Arial" and size"12":

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_CREATE, "HEADLINE", "" )

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_FONT_NAME, "Arial", "HEADLINE" )

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_FONT_SIZE, "12", "HEADLINE" )

 

Example for modifying the default text template with the font color "red"

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_COLOR, _

N2PDFVALUE_COLOR_RED, N2PDFVALUE_DEFAULT_PARAGRAPH_NAME )

 

Example for selecting the "HEADLINE" text template and inserting a text:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_Select, "HEADLINE", "" )

 

Call N2PDFAddContent ( JobID,_

N2PDFVALUE_CONTENT_BODY, 0, "Text" )

 

Below you will find a table with all the settings for configuring the text templates. The parameters are set using the function N2PDFSetOption. Selection of the respective options is made using the parameter <OptionID> while the values to be set are assigned with <OptionStr> and <SubOptionStr>.

 

N2PDFOPTION_PARAGRAPH_CREATE

This is the parameter you use to create a new text template. This new text template is initialized with the value defined above. You must assign the new template a name using <OptionStr>. This is the name used to reference the text template should you wish to modify or select it. Do not use any name that is already assigned to the predefined text templates.

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_CREATE, "HEADLINE", "" )

 

N2PDFOPTION_PARAGRAPH_SELECT

This parameter is utilized to select one of the created text templates and make it the one currently being used. Any further texts being inserted, such as through N2PDFAddContent, will be formatted using this text template.

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_Select, "HEADLINE", "" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_NAME

You use this parameter to change the font type of a given text template. Specify the name of the font with <OptionStr> and then use <SupOptionStr> to select the text template to be modified.

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_FONT_NAME, "Arial", "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_SIZE

You can change the font size of an existing text template using this parameter. Specify the size of the font with <OptionStr> and then use <SupOptionStr> to select the text template to be modified.

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_FONT_SIZE, "12", "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_COLOR

You can change the font color of an existing text template using this parameter. Specify the font's color with <OptionStr> and then use <SupOptionStr> to select the text template to be modified. The following constants are available for the colors:

 

N2PDFVALUE_COLOR_BLACK

N2PDFVALUE_COLOR_MAROON

N2PDFVALUE_COLOR_GREEN

N2PDFVALUE_COLOR_OLIVE

N2PDFVALUE_COLOR_NAVY

N2PDFVALUE_COLOR_PURPLE

N2PDFVALUE_COLOR_TEAL

N2PDFVALUE_COLOR_GRAY

N2PDFVALUE_COLOR_SILVER

N2PDFVALUE_COLOR_RED

N2PDFVALUE_COLOR_LIME

N2PDFVALUE_COLOR_YELLOW

N2PDFVALUE_COLOR_BLUE

N2PDFVALUE_COLOR_FUCHSIA

N2PDFVALUE_COLOR_AQUA

N2PDFVALUE_COLOR_WHITE

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_COLOR,_

N2PDFVALUE_COLOR_TEAL, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_BOLD

You can set the font style of an existing text template to "bold" using this parameter. Specify the mode with <OptionStr> and use <SupOptionStr> to select the text template to be modified.

 

N2PDFVALUE_TRUE

"Bold" on

N2PDFVALUE_FALSE

"Bold" off

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_FONT_BOLD, N2PDFVALUE_True, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_ITALIC

You can set the font style of an existing text template to "italic" using this parameter. Specify the mode with <OptionStr> and use <SupOptionStr> to select the text template to be modified.

 

N2PDFVALUE_TRUE

"Italic" on

N2PDFVALUE_FALSE

"Italic" off

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_FONT_ITALIC, N2PDFVALUE_True, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_UNDERLINE

You can set the font style of an existing text template to "underlined" using this parameter. Specify the mode with <OptionStr> and use <SupOptionStr> to select the text template to be modified.

 

N2PDFVALUE_TRUE

"Underlined" on

N2PDFVALUE_FALSE

"Underlined" off

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_UNDERLINE,_

N2PDFVALUE_True, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_SUPERSCRIPT

You can set the font style of an existing text template to "superscript" using this parameter. Specify the mode with <OptionStr> and use <SupOptionStr> to select the text template to be modified.

 

N2PDFVALUE_TRUE

"Superscript" on

N2PDFVALUE_FALSE

"Superscript" off

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_SUPERSCRIPT,_

N2PDFVALUE_True, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_SUBSCRIPT

You can set the font style of an existing text template to "subscript" using this parameter. Specify the mode with <OptionStr> and use <SupOptionStr> to select the text template to be modified.

 

N2PDFVALUE_TRUE

"Subscript" on

N2PDFVALUE_FALSE

"Subscript" off

 

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_SUBSCRIPT,_

N2PDFVALUE_True, "HEADLINE")

 

 

N2PDFOPTION_PARAGRAPH_FONT_STRIKEOUT

You can set the font style of an existing text template to "strikethrough" using this parameter. Specify the mode with <OptionStr> and use <SupOptionStr> to select the text template to be modified.

 

N2PDFVALUE_TRUE

"Strikethrough" on

N2PDFVALUE_FALSE

"Strikethrough" off

 

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_STRIKEOUT,_

N2PDFVALUE_True, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_PARACOLOR

With this parameter you can set the background color of a paragraph in an existing text template. Select the color with <OptionStr> and then use <SupOptionStr> to select the text template to be modified. The same color values are available as for <SubOptionStr> with N2PDFOPTION_PARAGRAPH_FONT_COLOR.

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_PARACOLOR,_

N2PDFVALUE_COLOR_NAVY, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_BGCOLOR

This parameter is used to set the background color for an existing text template. Select the color with <OptionStr> and then use <SupOptionStr> to select the text template to be modified. The same color values are available as for <SubOptionStr> with N2PDFOPTION_PARAGRAPH_FONT_COLOR.

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_BGCOLOR,_

N2PDFVALUE_COLOR_NAVY, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_FONT_ALIGNMENT

You can configure the text alignment for an existing text template using this parameter. Select the alignment with <OptionStr> and then use <SupOptionStr> to choose the text template to be modified. The same alignment values are available as for (<OptionStr>):

 

N2PDFVALUE_ALIGNMENT_LEFT

N2PDFVALUE_ALIGNMENT_RIGHT

N2PDFVALUE_ALIGNMENT_CENTER

N2PDFVALUE_ALIGNMENT_BLOCK

 

Example:

Call N2PDFSetOption ( JobID, N2PDFOPTION_PARAGRAPH_FONT_ALIGNMENT,_

N2PDFVALUE_ALIGNMENT_LEFT, "HEADLINE" )

 

 

N2PDFOPTION_PARAGRAPH_LINE_SPACING

This parameter allows the setting of the line spacing for an existing text template. Use <OptionStr> to select the line height and <SupOptionStra> to select the text template to be changed. Please note, that the selected value is that of the unit of measurement which has been defined in the "system settings". The value entered corresponds to the entire row height, including the text itself. In addition to being able to use the units of measurement cm/inch, it is also possible to set the value in "%" (300 % are equivalent to double spacing).

 

Important: In Version 2.0 of n2pdf the line spacing is no longer equivalent to the end of the text (image 2.) and the text beginning of the next line, but the distance between the text end of one line to the text end of the next line (image 1.).

 

 

clip0023

 

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_Line_SPACING, "2", "HEADLINE")

 

 

N2PDFOPTION_PARAGRAPH_TAB_LEFT

N2PDFOPTION_PARAGRAPH_TAB_RIGHT

N2PDFOPTION_PARAGRAPH_TAB_CENTER

N2PDFOPTION_PARAGRAPH_TAB_DECIMAL

These four parameters enable you to define a tab for an existing text template. Use <OptionStr> to select the type of tab and <SupOptionStr> to designate into which text template it is to be inserted. A tab to be inserted using N2PDFAddContent is defined in a plain text with the character Chr(9).

 

Example:

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_Tab_LEFT, "5", "HEADLINE")

 

 

N2PDFOPTION_PARAGRAPH_INDENT_LEFT

N2PDFOPTION_PARAGRAPH_INDENT_RIGHT

N2PDFOPTION_PARAGRAPH_INDENT_FIRST

These three parameters allow an indent for an existing text template. In addition to the left and right margin, you can also define the indent for the first line of a paragraph. A negative value for the first line will mean an outdent of the actual line. Set the value of the indent using <OptionStr>.

 

Example: Left margin 2 cm and outdent of the first line by 1 cm

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_INDENT_LEFT, "2", "")

 

Call N2PDFSetOption ( JobID,_

N2PDFOPTION_PARAGRAPH_INDENT_FIRST, "-1", "")

 

 

N2PDFOPTION_PARAGRAPH_CHARSET

This parameter can be used to alter the Character Set (Charset) for the text template. If you do not define this value, the standard response is for this setting to be removed from the operating system. If you do not wish to format texts using this template, which do not belong to the same language as the current setting of the operating system, you should at this point set the relevant character set. You will find the permitted values and other descriptions under "Unicode and Charset".