FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GemBox.Document.Examples/VB.NET/Elements/Fields/Program.vb at master · GemBoxLtd/GemBox.Document.Examples · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
GemBoxLtd
/
GemBox.Document.Examples
Public
Notifications
You must be signed in to change notification settings
Fork
35
Star
84
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
GemBox.Document.Examples
/
VB.NET
/
Elements
/
Fields
/
Program.vb
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (56 loc) · 2.8 KB
Breadcrumbs
GemBox.Document.Examples
/
VB.NET
/
Elements
/
Fields
/
Program.vb
Copy path
File metadata and controls
76 lines (56 loc) · 2.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Imports
GemBox.Document
Imports
System.Linq
Module
Program
Sub
Main()
Example1()
Example2()
End
Sub
Sub
Example1()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense(
"FREE-LIMITED-KEY"
)
Dim
document
As
New
DocumentModel()
Dim
section
As
New
Section(document)
document.Sections.Add(section)
' Add '{ AUTHOR }' field.
section.Blocks.Add(
New
Paragraph(document,
New
Run(document,
"Author: "
),
New
Field(document,
FieldType.Author,
Nothing
,
"Mario at GemBox"
)))
' Add '{ DATE }' field.
section.Blocks.Add(
New
Paragraph(document,
New
Run(document,
"Date: "
),
New
Field(document,
FieldType.Date)))
' Add '{ DATE \@ "dddd, MMMM dd, yyyy" }' field.
section.Blocks.Add(
New
Paragraph(document,
New
Run(document,
"Date with specified format: "
),
New
Field(document,
FieldType.Date,
"\@ ""dddd, MMMM dd, yyyy"""
)))
document.Save(
"Fields.docx"
)
End
Sub
Sub
Example2()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense(
"FREE-LIMITED-KEY"
)
Dim
document
=
New
DocumentModel()
Dim
section
=
New
Section(document)
document.Sections.Add(section)
' A simple '{ IF }' field, that will result on different texts if true or false.
Dim
simpleField
=
New
Field(document,
FieldType.If,
"10 = 10 ""The result Is True."" ""The result Is False."""
)
' A complex '{ IF }' field, that will result on texts with different formats if true or false.
Dim
complexField
=
New
Field(document,
FieldType.If,
New
Run(document,
"10 = 10 "
),
New
Run(document,
"""The result Is True."""
)
With
{.CharacterFormat
=
New
CharacterFormat()
With
{.FontColor
=
Color.Green,
.Bold
=
True
}},
New
Run(document,
"""The result Is False."""
)
With
{.CharacterFormat
=
New
CharacterFormat()
With
{.FontColor
=
Color.Red,
.Italic
=
True
}})
' Add both fields to the document.
section.Blocks.Add(
New
Paragraph(document,
simpleField))
section.Blocks.Add(
New
Paragraph(document,
complexField))
' Call Update method to resolve the field's value.
simpleField.Update()
complexField.Update()
' Get the result, which for simpleField will be a simple Run with "The result is true." as text.
Dim
simpleResult
=
simpleField.ResultElements.OfType(
Of
Run)().First()
' Get the result, which will be a Run with FontColor Green And Bold set to true.
Dim
complexResult
=
complexField.ResultElements.OfType(
Of
Run)().First()
document.Save(
"FieldsUpdated.docx"
)
End
Sub
End
Module
Back
|
FazBrowse Home
|
New Git URL