Wiki source code of Voraussetzung Word


Show last authors
1 {{content/}}
2
3 Actions of type //Fill word document// allow you to create a PDF document based on an existing word document.
4
5 Word form control element are replaced with the value of the corresponding form element. Use cases include summaries of contact forms or surveys.
6
7 == Word version ==
8
9 All versions starting from Word 97 are supported.
10
11 == Inserting values from form fields ==
12
13 {{figure image="WordDevTools.png" width="400"}}
14 //Developer tools// can be activated in the options under //customize ribbon// {{rarrow/}} //developer tools//.
15 {{/figure}}
16
17 To insert values from the form into the the word document, you need to add form control elements to the word document.
18
19 Form controls are found under the //developer tools// tab. In case this tab is not available, activate it by going to //files// {{rarrow/}} //options// {{rarrow/}} //customize ribbon// {{rarrow/}} //developer tools//.
20
21 {{figure image="WordElement.png" width="400"}}
22 Go to the developer tools tab to insert a text field form control. Give it a name and it will be replaced with the value of that form element.
23 {{/figure}}
24
25 Click on the //developer tools// tab and insert a //text field//. Double click on the text field, which opens a new window. Enter the name of the form element under //default text//. This text field is then replaced with the value of the form element with that name.
26
27 {{info}}
28 If the form element is a repeated element, the text field is replaced with the value of all dynamically created fields separated by a comma. For example, if there are three dynamic field, the value could be //Anton,Sabine,Odo//.
29 {{/info}}
30
31 {{info}}
32 The value of form elements is visible in the document. When you wish to avoid that, you can set the word function as the help text of the form element. When the help text contains a function, that function always takes precedence over functions in the value of form elements.
33 {{/info}}
34
35
36 See also [[repeated fields>>Formcycle.Designer.Form.ElementProperties.BaseProperties]].
37
38 == Example ==
39
40 {{figure image="WordFillExample2.png" width="400"}}
41 Example for how to insert data from a form into a word document. Form fields are selected based upon their name and the default text of the form control element.
42 {{/figure}}
43
44 In this example, the text field form control with the default text //tfFirstName// is replaced with the content of the form element named //tfFirstName//. Similarly, the text field form control //tfLastName// and //tfQuestion// are replaced with the corresponding form elements as well.
45
46 == Word fill functions ==
47
48 Sometimes it is necessary to transform or edit the raw value of a form element before inserting it into the word document. This can be achieved with the following functions.
49
50 As an example, consider a form element of type [[selection>>Formcycle.Designer.Form.FormElements.Selection]]. Its value is often numeric, eg. //0// (for //no//) or //1// (for //yes//). If you would like to insert the name of the option instead, use the function //lsttxt()//. That is, if the form element is named //selQuestion//, use //selQuestion.lsttxt()// as the default name for the form field control in the word document.
51
52 {{code language="none"}}
53 selQuestion.lsttxt()
54 {{/code}}
55
56 === Format ===
57
58 Word fill funktionen always have the following syntax (quotation marks are supported since {{version major="7" minor="1"/}}):
59
60 ==== Word function ====
61
62 {{code language="none"}}
63 <Word-Function> = <Field-Name> ["." <Function-Name> "(" <Argument>? ")" ] *
64 {{/code}}
65
66 A word function consists of the name of a form field, followed by any number of functions, separated with a dot. Each function may also specify an optional argument, but does not have to.
67
68 {{code language="none"}}
69 sel1
70 sel1.function1()
71 sel1.function1(argument)
72 sel1.function1().funktion2()
73 sel1.function1(argument).function2().function3()
74 {{/code}}
75
76 ==== Argument ====
77
78 {{code language="none"}}
79 <Argument> = <ArgList> | <ArgMap>
80 {{/code}}
81
82 The argument can be either a list of values or a mapping between keys and values. Which type of argument needs to be used depends on the function.
83
84 ==== ArgList ====
85
86 {{code language="none"}}
87 <ArgList> = <Value> [ "|" <Value> ] *
88 {{/code}}
89
90 The argument can be a list of values, separated by a bar character. The number of required arguments depends on the function.
91
92 {{code language="none"}}
93 sel1.function(value1)
94 sel1.function(value1|value2)
95 sel1.function(value1|value2|value3)
96 {{/code}}
97
98 ==== ArgMap ====
99
100 {{code language="none"}}
101 <ArgMap> = <ArgList> "#" <ArgList>
102 {{/code}}
103
104 The argument can also be a mapping between keys and values. The keys and values are separated by hash tag. Which keys are required depends on the function.
105
106 {{code language="none"}}
107 sel1.function(key1#value1)
108 sel1.function(key1|key2#value1|value2)
109 sel1.function(key1|key2|key3#value1|value2|value3)
110 {{/code}}
111
112 ==== Value ====
113
114 {{code language="none"}}
115 <Value> = <Unquoted-String> | <Singly-Quoted-String> | <Doubly-Quoted-String>
116 {{/code}}
117
118 Each value can be just a series of characters.
119
120 {{code language="none"}}
121 sel1.function(Ein Wert)
122 sel1.function(Noch ein Wert)
123 sel1.function(Wert1|Wert2)
124 {{/code}}
125
126 Certain special characters such as parentheses or hash tags cannot be used normally. Then it is also possible to put the value in single or double quotes (supported since {{version major="7" minor="1"/}}). Values without quotation marks exist for compatibility reasons, the use of quotation marks is recomended and never wrong.
127
128 {{code language="none"}}
129 sel1.function('Value (with) parentheses')
130 sel1.function("Value with a dot and a hash tag #.")
131 sel1.function('Value#1'|'Value#2')
132 {{/code}}
133
134 You can also use escape sequences within quoted values:
135
136 {{code language="none"}}
137 sel1.function("John said: \"It rains\"")
138 sel1.function("The backslash \\ starts an escape sequence")
139 sel1.function("Line break: \r\n")
140 sel1.function("Tab: \t")
141 sel1.function("Unicode character: \u578b")
142 {{/code}}
143
144 Note: When quotation marks are not used, all spaces belong to the value. The following are two distinct values (with and without a leading space):
145
146 {{code language="none"}}
147 sel1.function(Test)
148 sel1.function( Test)
149 {{/code}}
150
151 If you use quotation marks, spaces are ignored. The following is the same:
152
153 {{code language="none"}}
154 sel1.function("Test")
155 sel1.function( "Test")
156 {{/code}}
157
158 == Available function ==
159
160 {{table dataTypeAlpha="0" preSort="0"}}
161 |= Function |= Description|= Examples|= Explanation
162 | empty {{version major="7" minor="2"/}}|Checks whether the list of values is empty or one of the values is empty.|sel1.empty() |Returns //1// when no option or an option with an empty value was selected for a [[select element>>Formcycle.Designer.Form.FormElements.Selection]]. Otherwise, returns //0//.
163 | lsttxt |Replaces the value of the option of a selection element with its text (display) value. Stands for //list text.//|sel1.lsttxt() |Returns the text value of the selected option of the [[selection element>>Formcycle.Designer.Form.FormElements.Selection]] with the name //sel1//.
164 | lsttitle |Replace the value of the selected option of a selection element with its title. Stands for //list title//.|sel1.lsttitle() |Returns the title (if given) of the selected option of the selection element with the name //sel1//.
165 | lst |Replaces all values of a select element with the corresponding value of a certain column from the data source that provides the options for the select element. The name of the column must be given as an argument. When the data source does not given any names for its columns, you must use //col0//, //col1//, //col2// etc.|sel1.lst("CountryName")|Returns the value of the column with the name "CountryName" from the data source of the select element with name //sel1//.
166 | con |Checks whether the value exists in the list. Useful for selection elements with multiple choices. Stands for //contains.//|sel1.con("5") |Returns //1// if an option with the value //1// was selected for the selection element named //sel1//, or //0// otherwise.
167 | cnt |Counts the number of values for dynamic elements. Stands for //count//.| sel1.cnt() |Returns the number of dynamically generated elements for the [[dynamic>>Formcycle.Designer.Form.ElementProperties.BaseProperties]] selection element //sel1//.
168 | rmp |Deletes the current paragraph if the value is empty. Stands for //remove paragraph.// |tf1.rmp() |Deletes the current paragraph if the form element //tf1// is empty.
169 | rmr |Deletes the current table row. Stands for //remove row.// |{{{tf1.rmr("x")}}} |Deletes the current row of the table if the text field //tf1// has a value equal to //x//.
170 | rmt |Deletes the current table. Stands for //remove table.// |{{{tf1.rmt("y")}}}|Deletes the current table if the text field //EL1// has a value equal to //y//.
171 | rmtp |Deletes the current table and the following paragraph. Stands for //remove table paragraph//. |{{{tf1.rmtp("y")}}} |Deletes the current table and the following paragraphs if the text field //tf1// has a value equal to //y//.
172 | rep |Replaces the value with another value. The argument syntax is {{code language="none"}}EL.rep("W1"|"W2"#"R1"|"R2"){{/code}} or {{code language="none"}}EL.rep("W1"#"R1"){{/code}}. Stands for //replace.//|EL1.rep("on"~|"off"#"x"~|"o") |The value //on// is replaced with //x//and the value //off// is replaced with //o//.
173 | cf |Changes the character set to //Wingdings//. Mostly used in combination with the //rep// function. Stands for //change font//. |SEL1.rep(on~|off#x~|o).cf() |The value //on// is replaced with //x//, //off// with //o//. Afterwards the values //x// and //o// are replaced with their corresponding Wingdings symbols (cross and circle).
174 | image |Interprets the value as an URL and replaces it with the image found at that URL. You can also set width and height for the image. |tf1.image(), tf1.image("100"~|"100"), tf1.image("100"), tf1.image(~|"100") |Inserts an image found at the URL pointed to by the value of the text field //tf1//. Examples for height specifications: {{code language="none"}}tf1.image(width|height){{/code}}, eg. {{code language="none"}}tf1.image("579"|"410"){{/code}}. If you only specify an width ({{code language="none"}}tf1.image("579"){{/code}}) or height ({{code language="none"}}tf1.image(|"410"){{/code}}), the resulting image will be scaled to maintain the aspect ratio.
175 | b64img |Converts a base64 string to an image. You can also transfer width and height information. |tf1.b64img(), tf1.b64img("100"~|"100"), tf1.b64img("100"), tf1.b64img(~|"100") |Interpretes the field value as a base64 string and inserts it as an image into the document. The base64 string should look like //iVBORw0KGgoAAAANSUhEUgAAABAAAA...//. Examples for height specifications: {{code language="none"}}tf1.b64img("width"|"height"){{/code}}, eg. {{code language="none"}}tf1.b64img("579"|"410"){{/code}}. If you only specify an width ({{code language="none"}}tf1.b64img("579"){{/code}}) or height ({{code language="none"}}tf1.b64img(|"410"){{/code}}), the resulting image will be scaled to maintain the aspect ratio.
176 | url |Interprets the value as an URL and generates a link to that URL. | tf1.url() |Adds a link to the PDF document with the address taken from the value of the text field //tf1//.
177 | cb |Generates a checked [[checkbox>>Formcycle.Designer.Form.FormElements.Checkbox]] if the the value contains the given parameter. Generates an unchecked checkbox otherwise. Stands for //Checkbox//.| SEL1.cb("1") |Generates a checked checkbox, if there is a selected option with the value //1// for the selection element //SEL1//, or an unchecked checkbox otherwise.
178 {{/table}}
179
180 == Problems creating checkboxes ==
181
182 If no checkboxes are created in the generated PDF document when using the function //cb()//, it is probably due to missing fonts on the server. This problem usually occurs only when {{formcycle/}} is installed on a Linux server.
183
184 To solve the problem, try:
185
186 * Log in to the Linux server with {{formcycle/}}
187
188 * Go to the system fonts folder (eg. ///usr/share/fonts/truetype/// for Debian/Ubuntu) and check whether the fonts //windings.ttf// and //windings2.ttf// are installed.
189
190 * If not, copy these fonts to the folder. Due to licensing issues we cannot ship the product with these fonts, so you must copy them yourself from a Windows installation.
191
192 * Restart the Tomcat server.
193
194 == Placeholder replacement ==
195
196 It is possible to insert placeholders into the created form control elements.
197
198 == Insert HTML {{version major="7" minor="2"/}} ==
199
200 {{figure image="addField_en.png" width="400"}}
201 Adding a field.
202 {{/figure}}
203
204 {{figure image="mergeField_en.png" width="400"}}
205 Creating a //MergeField//.
206 {{/figure}}
207
208 In case the text value of the form elements or placeholders need to be interpreted as HTML, they have to be added through //MergeFields//. //MergeFields// can be inserted through //Insert// {{rarrow/}} //Quick Parts// {{rarrow/}} //Field//. In the pop up window, under the menu //Place choose a field//, the field name //MergeField// has to be selected. After selecting //MergeFields//, under the menu //Field properties//, in the field //Field name//, the name of the form element or placeholder has to be inserted.