-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InsertMergeFieldUsingDOM InsertMailMergeAddressBlockFieldUsingDOM InsertAdvanceFieldWithOutDocumentBuilder InsertASKFieldWithOutDocumentBuilder InsertAuthorField
- Loading branch information
Showing
17 changed files
with
506 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Examples/CSharp/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
|
||
using Aspose.Words; | ||
using Aspose.Words.Tables; | ||
using Aspose.Words.Fields; | ||
using Aspose.Words.Layout; | ||
|
||
namespace CSharp.Programming_Documents.Working_with_Fields | ||
{ | ||
class InsertASKFieldWithOutDocumentBuilder | ||
{ | ||
public static void Run() | ||
{ | ||
//ExStart:InsertASKFieldWithOutDocumentBuilder | ||
// The path to the documents directory. | ||
string dataDir = RunExamples.GetDataDir_WorkingWithFields(); | ||
Document doc = new Document(dataDir + "in.doc"); | ||
// Get paragraph you want to append this Ask field to | ||
Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1]; | ||
|
||
// We want to insert an Ask field like this: | ||
// { ASK \"Test 1\" Test2 \\d Test3 \\o } | ||
|
||
// Create instance of FieldAsk class and lets build the above field code | ||
FieldAsk field = (FieldAsk)para.AppendField(FieldType.FieldAsk, false); | ||
|
||
// { ASK \"Test 1\" " } | ||
field.BookmarkName = "Test 1"; | ||
|
||
// { ASK \"Test 1\" Test2 } | ||
field.PromptText = "Test2"; | ||
|
||
// { ASK \"Test 1\" Test2 \\d Test3 } | ||
field.DefaultResponse = "Test3"; | ||
|
||
// { ASK \"Test 1\" Test2 \\d Test3 \\o } | ||
field.PromptOnceOnMailMerge = true; | ||
|
||
// Finally update this Ask field | ||
field.Update(); | ||
|
||
dataDir = dataDir + "InsertASKFieldWithOutDocumentBuilder_out_.doc"; | ||
doc.Save(dataDir); | ||
|
||
//ExEnd:InsertASKFieldWithOutDocumentBuilder | ||
Console.WriteLine("\nASK field without using document builder inserted successfully.\nFile saved at " + dataDir); | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Examples/CSharp/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
|
||
using Aspose.Words; | ||
using Aspose.Words.Tables; | ||
using Aspose.Words.Fields; | ||
using Aspose.Words.Layout; | ||
|
||
namespace CSharp.Programming_Documents.Working_with_Fields | ||
{ | ||
class InsertAdvanceFieldWithOutDocumentBuilder | ||
{ | ||
public static void Run() | ||
{ | ||
//ExStart:InsertAdvanceFieldWithOutDocumentBuilder | ||
// The path to the documents directory. | ||
string dataDir = RunExamples.GetDataDir_WorkingWithFields(); | ||
Document doc = new Document(dataDir + "in.doc"); | ||
// Get paragraph you want to append this Advance field to | ||
Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1]; | ||
|
||
// We want to insert an Advance field like this: | ||
// { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 } | ||
|
||
// Create instance of FieldAdvance class and lets build the above field code | ||
FieldAdvance field = (FieldAdvance)para.AppendField(FieldType.FieldAdvance, false); | ||
|
||
|
||
// { ADVANCE \\d 10 " } | ||
field.DownOffset = "10"; | ||
|
||
// { ADVANCE \\d 10 \\l 10 } | ||
field.LeftOffset = "10"; | ||
|
||
// { ADVANCE \\d 10 \\l 10 \\r -3.3 } | ||
field.RightOffset = "-3.3"; | ||
|
||
// { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 } | ||
field.UpOffset = "0"; | ||
|
||
// { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 } | ||
field.HorizontalPosition = "100"; | ||
|
||
// { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 } | ||
field.VerticalPosition = "100"; | ||
|
||
// Finally update this Advance field | ||
field.Update(); | ||
|
||
dataDir = dataDir + "InsertAdvanceFieldWithOutDocumentBuilder_out_.doc"; | ||
doc.Save(dataDir); | ||
|
||
//ExEnd:InsertAdvanceFieldWithOutDocumentBuilder | ||
Console.WriteLine("\nAdvance field without using document builder inserted successfully.\nFile saved at " + dataDir); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Examples/CSharp/Programming-Documents/Fields/InsertAuthorField.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
|
||
using Aspose.Words; | ||
using Aspose.Words.Tables; | ||
using Aspose.Words.Fields; | ||
using Aspose.Words.Layout; | ||
|
||
namespace CSharp.Programming_Documents.Working_with_Fields | ||
{ | ||
class InsertAuthorField | ||
{ | ||
public static void Run() | ||
{ | ||
//ExStart:InsertAuthorField | ||
// The path to the documents directory. | ||
string dataDir = RunExamples.GetDataDir_WorkingWithFields(); | ||
Document doc = new Document(dataDir + "in.doc"); | ||
// Get paragraph you want to append this AUTHOR field to | ||
Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1]; | ||
|
||
// We want to insert an AUTHOR field like this: | ||
// { AUTHOR Test1 } | ||
|
||
// Create instance of FieldAuthor class and lets build the above field code | ||
FieldAuthor field = (FieldAuthor)para.AppendField(FieldType.FieldAuthor, false); | ||
|
||
// { AUTHOR Test1 } | ||
field.AuthorName = "Test1"; | ||
|
||
// Finally update this AUTHOR field | ||
field.Update(); | ||
|
||
dataDir = dataDir + "InsertAuthorField_out_.doc"; | ||
doc.Save(dataDir); | ||
//ExEnd:InsertAuthorField | ||
Console.WriteLine("\nAuthor field without document builder inserted successfully.\nFile saved at " + dataDir); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Examples/CSharp/Programming-Documents/Fields/InsertMailMergeAddressBlockFieldUsingDOM.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
|
||
using Aspose.Words; | ||
using Aspose.Words.Tables; | ||
using Aspose.Words.Fields; | ||
using Aspose.Words.Layout; | ||
|
||
namespace CSharp.Programming_Documents.Working_with_Fields | ||
{ | ||
class InsertMailMergeAddressBlockFieldUsingDOM | ||
{ | ||
public static void Run() | ||
{ | ||
//ExStart:InsertMailMergeAddressBlockFieldUsingDOM | ||
// The path to the documents directory. | ||
string dataDir = RunExamples.GetDataDir_WorkingWithFields(); | ||
Document doc = new Document(dataDir + "in.doc"); | ||
DocumentBuilder builder = new DocumentBuilder(doc); | ||
|
||
// Get paragraph you want to append this merge field to | ||
Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1]; | ||
|
||
// Move cursor to this paragraph | ||
builder.MoveTo(para); | ||
|
||
// We want to insert a mail merge address block like this: | ||
// { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 \\l \"Test 4\" } | ||
|
||
// Create instance of FieldAddressBlock class and lets build the above field code | ||
FieldAddressBlock field = (FieldAddressBlock)builder.InsertField(FieldType.FieldAddressBlock, false); | ||
|
||
// { ADDRESSBLOCK \\c 1" } | ||
field.IncludeCountryOrRegionName = "1"; | ||
|
||
// { ADDRESSBLOCK \\c 1 \\d" } | ||
field.FormatAddressOnCountryOrRegion = true; | ||
|
||
// { ADDRESSBLOCK \\c 1 \\d \\e Test2 } | ||
field.ExcludedCountryOrRegionName = "Test2"; | ||
|
||
// { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 } | ||
field.NameAndAddressFormat = "Test3"; | ||
|
||
// { ADDRESSBLOCK \\c 1 \\d \\e Test2 \\f Test3 \\l \"Test 4\" } | ||
field.LanguageId = "Test 4"; | ||
|
||
// Finally update this merge field | ||
field.Update(); | ||
|
||
dataDir = dataDir + "InsertMailMergeAddressBlockFieldUsingDOM_out_.doc"; | ||
doc.Save(dataDir); | ||
|
||
//ExEnd:InsertMailMergeAddressBlockFieldUsingDOM | ||
Console.WriteLine("\nMail Merge address block field using DOM inserted successfully.\nFile saved at " + dataDir); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Examples/CSharp/Programming-Documents/Fields/InsertMergeFieldUsingDOM.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
|
||
using Aspose.Words; | ||
using Aspose.Words.Tables; | ||
using Aspose.Words.Fields; | ||
using Aspose.Words.Layout; | ||
|
||
namespace CSharp.Programming_Documents.Working_with_Fields | ||
{ | ||
class InsertMergeFieldUsingDOM | ||
{ | ||
public static void Run() | ||
{ | ||
//ExStart:InsertMergeFieldUsingDOM | ||
// The path to the documents directory. | ||
string dataDir = RunExamples.GetDataDir_WorkingWithFields(); | ||
Document doc = new Document(dataDir + "in.doc"); | ||
DocumentBuilder builder = new DocumentBuilder(doc); | ||
|
||
// Get paragraph you want to append this merge field to | ||
Paragraph para = (Paragraph)doc.GetChildNodes(NodeType.Paragraph, true)[1]; | ||
|
||
// Move cursor to this paragraph | ||
builder.MoveTo(para); | ||
|
||
// We want to insert a merge field like this: | ||
// { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m \\v" } | ||
|
||
// Create instance of FieldMergeField class and lets build the above field code | ||
FieldMergeField field = (FieldMergeField)builder.InsertField(FieldType.FieldMergeField, false); | ||
|
||
// { " MERGEFIELD Test1" } | ||
field.FieldName = "Test1"; | ||
|
||
// { " MERGEFIELD Test1 \\b Test2" } | ||
field.TextBefore = "Test2"; | ||
|
||
// { " MERGEFIELD Test1 \\b Test2 \\f Test3 } | ||
field.TextAfter = "Test3"; | ||
|
||
// { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m" } | ||
field.IsMapped = true; | ||
|
||
// { " MERGEFIELD Test1 \\b Test2 \\f Test3 \\m \\v" } | ||
field.IsVerticalFormatting = true; | ||
|
||
// Finally update this merge field | ||
field.Update(); | ||
|
||
dataDir = dataDir + "InsertMergeFieldUsingDOM_out_.doc"; | ||
doc.Save(dataDir); | ||
|
||
//ExEnd:InsertMergeFieldUsingDOM | ||
Console.WriteLine("\nMerge field using DOM inserted successfully.\nFile saved at " + dataDir); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-6.05 KB
Examples/Data/Programming-Documents/Fields/InsertNestedFields_out_.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
41 changes: 41 additions & 0 deletions
41
Examples/VisualBasic/Programming-Documents/Fields/InsertASKFieldWithOutDocumentBuilder.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Imports Microsoft.VisualBasic | ||
Imports System.IO | ||
Imports Aspose.Words | ||
Imports Aspose.Words.Fields | ||
Public Class InsertASKFieldWithOutDocumentBuilder | ||
Public Shared Sub Run() | ||
' ExStart:InsertASKFieldWithOutDocumentBuilder | ||
' The path to the documents directory. | ||
Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields() | ||
Dim doc As New Document(dataDir & Convert.ToString("in.doc")) | ||
' Get paragraph you want to append this Ask field to | ||
Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph) | ||
|
||
' We want to insert an Ask field like this: | ||
' { ASK \"Test 1\" Test2 \\d Test3 \\o } | ||
|
||
' Create instance of FieldAsk class and lets build the above field code | ||
Dim field As FieldAsk = DirectCast(para.AppendField(FieldType.FieldAsk, False), FieldAsk) | ||
|
||
' { ASK \"Test 1\" " } | ||
field.BookmarkName = "Test 1" | ||
|
||
' { ASK \"Test 1\" Test2 } | ||
field.PromptText = "Test2" | ||
|
||
' { ASK \"Test 1\" Test2 \\d Test3 } | ||
field.DefaultResponse = "Test3" | ||
|
||
' { ASK \"Test 1\" Test2 \\d Test3 \\o } | ||
field.PromptOnceOnMailMerge = True | ||
|
||
' Finally update this Ask field | ||
field.Update() | ||
|
||
dataDir = dataDir & Convert.ToString("InsertASKFieldWithOutDocumentBuilder_out_.doc") | ||
doc.Save(dataDir) | ||
|
||
' ExEnd:InsertASKFieldWithOutDocumentBuilder | ||
Console.WriteLine(Convert.ToString(vbLf & "ASK field without using document builder inserted successfully." & vbLf & "File saved at ") & dataDir) | ||
End Sub | ||
End Class |
48 changes: 48 additions & 0 deletions
48
...ples/VisualBasic/Programming-Documents/Fields/InsertAdvanceFieldWithOutDocumentBuilder.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Imports Microsoft.VisualBasic | ||
Imports System.IO | ||
Imports Aspose.Words | ||
Imports Aspose.Words.Fields | ||
Public Class InsertAdvanceFieldWithOutDocumentBuilder | ||
Public Shared Sub Run() | ||
' ExStart:InsertAdvanceFieldWithOutDocumentBuilder | ||
' The path to the documents directory. | ||
Dim dataDir As String = RunExamples.GetDataDir_WorkingWithFields() | ||
Dim doc As New Document(dataDir & Convert.ToString("in.doc")) | ||
' Get paragraph you want to append this Advance field to | ||
Dim para As Paragraph = DirectCast(doc.GetChildNodes(NodeType.Paragraph, True)(1), Paragraph) | ||
|
||
' We want to insert an Advance field like this: | ||
' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 } | ||
|
||
' Create instance of FieldAdvance class and lets build the above field code | ||
Dim field As FieldAdvance = DirectCast(para.AppendField(FieldType.FieldAdvance, False), FieldAdvance) | ||
|
||
|
||
' { ADVANCE \\d 10 " } | ||
field.DownOffset = "10" | ||
|
||
' { ADVANCE \\d 10 \\l 10 } | ||
field.LeftOffset = "10" | ||
|
||
' { ADVANCE \\d 10 \\l 10 \\r -3.3 } | ||
field.RightOffset = "-3.3" | ||
|
||
' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 } | ||
field.UpOffset = "0" | ||
|
||
' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 } | ||
field.HorizontalPosition = "100" | ||
|
||
' { ADVANCE \\d 10 \\l 10 \\r -3.3 \\u 0 \\x 100 \\y 100 } | ||
field.VerticalPosition = "100" | ||
|
||
' Finally update this Advance field | ||
field.Update() | ||
|
||
dataDir = dataDir & Convert.ToString("InsertAdvanceFieldWithOutDocumentBuilder_out_.doc") | ||
doc.Save(dataDir) | ||
|
||
' ExEnd:InsertAdvanceFieldWithOutDocumentBuilder | ||
Console.WriteLine(Convert.ToString(vbLf & "Advance field without using document builder inserted successfully." & vbLf & "File saved at ") & dataDir) | ||
End Sub | ||
End Class |
Oops, something went wrong.