Skip to content

Commit 4459a30

Browse files
Merge pull request #302 from SureshGanesanSF4645/main
Update GitHub for FT sample
2 parents 4485df6 + 7a68381 commit 4459a30

File tree

36 files changed

+184
-77
lines changed

36 files changed

+184
-77
lines changed

Bookmarks/Add-bookmark-in-Word-document/.NET/Add-bookmark-in-Word-document/Program.cs

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ static void Main(string[] args)
1111
//Creates a new Word document.
1212
using (WordDocument document = new WordDocument())
1313
{
14-
//Adds a new section into the Word Document.
15-
IWSection section = document.AddSection();
16-
//Adds a new paragraph into Word document and appends text into paragraph.
17-
IWParagraph paragraph = section.AddParagraph();
18-
paragraph.AppendText("Northwind Database");
19-
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
20-
//Adds a paragraph into section.
21-
paragraph = section.AddParagraph();
14+
//Add a new section and paragraph in the document.
15+
document.EnsureMinimal();
16+
//Get the last paragraph.
17+
IWParagraph paragraph = document.LastParagraph;
2218
//Adds a new bookmark start into paragraph with name "Northwind".
2319
paragraph.AppendBookmarkStart("Northwind");
2420
//Adds a text between the bookmark start and end into paragraph.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35327.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fill-simple-form", "Fill-simple-form\Fill-simple-form.csproj", "{BD83DEC5-BB86-4647-8562-513E15DF50BD}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BD83DEC5-BB86-4647-8562-513E15DF50BD}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {986E28DE-AA32-41F5-A66C-CBF891692255}
24+
EndGlobalSection
25+
EndGlobal
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Fill_simple_form_Word_doocument</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Template.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.IO;
4+
5+
//Open the file as stream.
6+
using (FileStream inputDocumentStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
7+
{
8+
//Create a new Word document.
9+
using (WordDocument document = new WordDocument(inputDocumentStream, FormatType.Docx))
10+
{
11+
//Find drop-down content control by title.
12+
InlineContentControl inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Title", "Status") as InlineContentControl;
13+
WTextRange textRange = inlineContentControl.ParagraphItems[0] as WTextRange;
14+
//Select drop-down
15+
textRange.Text = inlineContentControl.ContentControlProperties.ContentControlListItems[1].DisplayText;
16+
17+
//Find date content control by tag.
18+
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Tag", "Date") as InlineContentControl;
19+
textRange = inlineContentControl.ParagraphItems[0] as WTextRange;
20+
//Set today's date to display.
21+
textRange.Text = DateTime.Now.ToShortDateString();
22+
23+
//Find text content control by title.
24+
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Title", "ProjectName") as InlineContentControl;
25+
//Fill text.
26+
textRange = inlineContentControl.ParagraphItems[0] as WTextRange;
27+
textRange.Text = "Website for Adventure works cycle";
28+
29+
//Find checkbox content control by type.
30+
inlineContentControl = document.FindItemByProperty(EntityType.InlineContentControl, "ContentControlProperties.Type", "CheckBox") as InlineContentControl;
31+
//Check the checkbox
32+
inlineContentControl.ContentControlProperties.IsChecked = true;
33+
34+
//Create file stream.
35+
using (FileStream outputDocumentStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
36+
{
37+
//Save the Word document to file stream.
38+
document.Save(outputDocumentStream, FormatType.Docx);
39+
}
40+
}
41+
}

HTML-conversions/Convert-Word-to-HTML/.NET/Convert-Word-to-HTML/Output/WordToHtml.html

+43
Large diffs are not rendered by default.

Security/Remove-encryption-from-Word-document/.NET/Remove-encryption-from-Word-document/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ static void Main(string[] args)
1111
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.ReadWrite))
1212
{
1313
//Opens an encrypted Word document.
14-
using (WordDocument document = new WordDocument(fileStream, "syncfusion"))
14+
using (WordDocument document = new WordDocument(fileStream, FormatType.Docx, "syncfusion"))
1515
{
1616
//Removes encryption in Word document.
1717
document.RemoveEncryption();
1818
//Creates file stream.
19-
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
19+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
2020
{
2121
//Saves the Word document to file stream.
2222
document.Save(outputStream, FormatType.Docx);

Security/Remove-encryption-from-Word-document/.NET/Remove-encryption-from-Word-document/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ Step 4: Add the following code snippet in Program.cs file to decrypt a Word docu
2222
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.ReadWrite))
2323
{
2424
//Opens an encrypted Word document.
25-
using (WordDocument document = new WordDocument(fileStream, "syncfusion"))
25+
using (WordDocument document = new WordDocument(fileStream, FormatType.Docx, "syncfusion"))
2626
{
2727
//Removes encryption in Word document.
2828
document.RemoveEncryption();
2929
//Creates file stream.
30-
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
30+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
3131
{
3232
//Saves the Word document to file stream.
3333
document.Save(outputStream, FormatType.Docx);
Binary file not shown.

Tables/Create-simple-table/.NET/Create-simple-table/Program.cs

+12-37
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,19 @@ static void Main(string[] args)
1111
//Creates a new Word document.
1212
using (WordDocument document = new WordDocument())
1313
{
14-
//Adds a section into Word document.
15-
IWSection section = document.AddSection();
16-
//Adds a new paragraph into Word document and appends text into paragraph.
17-
IWTextRange textRange = section.AddParagraph().AppendText("Price Details");
18-
textRange.CharacterFormat.FontName = "Arial";
19-
textRange.CharacterFormat.FontSize = 12;
20-
textRange.CharacterFormat.Bold = true;
21-
section.AddParagraph();
22-
//Adds a new table into Word document.
23-
IWTable table = section.AddTable();
24-
//Specifies the total number of rows & columns.
14+
//Add a section and a paragraph to the document.
15+
document.EnsureMinimal();
16+
//Add a new table to the Word document.
17+
IWTable table = document.Sections[0].AddTable();
18+
//Specify the total number of rows and columns.
2519
table.ResetCells(3, 2);
26-
//Accesses the instance of the cell (first row, first cell) and adds the content into cell.
27-
textRange = table[0, 0].AddParagraph().AppendText("Item");
28-
textRange.CharacterFormat.FontName = "Arial";
29-
textRange.CharacterFormat.FontSize = 12;
30-
textRange.CharacterFormat.Bold = true;
31-
//Accesses the instance of the cell (first row, second cell) and adds the content into cell.
32-
textRange = table[0, 1].AddParagraph().AppendText("Price($)");
33-
textRange.CharacterFormat.FontName = "Arial";
34-
textRange.CharacterFormat.FontSize = 12;
35-
textRange.CharacterFormat.Bold = true;
36-
//Accesses the instance of the cell (second row, first cell) and adds the content into cell.
37-
textRange = table[1, 0].AddParagraph().AppendText("Apple");
38-
textRange.CharacterFormat.FontName = "Arial";
39-
textRange.CharacterFormat.FontSize = 10;
40-
//Accesses the instance of the cell (second row, second cell) and adds the content into cell.
41-
textRange = table[1, 1].AddParagraph().AppendText("50");
42-
textRange.CharacterFormat.FontName = "Arial";
43-
textRange.CharacterFormat.FontSize = 10;
44-
//Accesses the instance of the cell (third row, first cell) and adds the content into cell.
45-
textRange = table[2, 0].AddParagraph().AppendText("Orange");
46-
textRange.CharacterFormat.FontName = "Arial";
47-
textRange.CharacterFormat.FontSize = 10;
48-
//Accesses the instance of the cell (third row, second cell) and adds the content into cell.
49-
textRange = table[2, 1].AddParagraph().AppendText("30");
50-
textRange.CharacterFormat.FontName = "Arial";
51-
textRange.CharacterFormat.FontSize = 10;
20+
//Access each table cell and append text.
21+
table[0, 0].AddParagraph().AppendText("Item");
22+
table[0, 1].AddParagraph().AppendText("Price($)");
23+
table[1, 0].AddParagraph().AppendText("Apple");
24+
table[1, 1].AddParagraph().AppendText("50");
25+
table[2, 0].AddParagraph().AppendText("Orange");
26+
table[2, 1].AddParagraph().AppendText("30");
5227
//Creates file stream.
5328
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite))
5429
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Northwind Database
2+
3+
The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases. Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data..
4+
5+
It contains the following detailed information:
6+
1. Suppliers/Vendors of Northwind – who supply to the company.
7+
2. Customers of Northwind – who buy from Northwind
8+
3. Employee details of Northwind traders – who work for Northwind
9+
4. The product information – the products that Northwind trades in
10+
5. The inventory details – the details of the inventory held by Northwind traders.
11+
6. The shippers – details of the shippers who ship the products from the traders to the end-customers
12+
7. PO transactions i.e Purchase Order transactions – details of the transactions taking place between vendors & the company.
13+
8. Sales Order transaction – details of the transactions taking place between the customers & the company.
14+
9. Inventory transactions – details of the transactions taking place in the inventory
15+
10. Invoices – details of the invoice raised against the order.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Word-document/Split-by-section/.NET/Split-by-section/Program.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,20 @@ static void Main(string[] args)
1313
//Load the template document as stream
1414
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
1515
{
16-
int fileId = 1;
1716
//Iterate each section from Word document
18-
foreach (WSection section in document.Sections)
17+
for (int i = 0; i < document.Sections.Count; i++)
1918
{
2019
//Create new Word document
2120
using (WordDocument newDocument = new WordDocument())
2221
{
2322
//Add cloned section into new Word document
24-
newDocument.Sections.Add(section.Clone());
23+
newDocument.Sections.Add(document.Sections[i].Clone());
2524
//Saves the Word document to MemoryStream
26-
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Section") + fileId + ".docx", FileMode.OpenOrCreate, FileAccess.ReadWrite))
25+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Section") + i + ".docx", FileMode.OpenOrCreate, FileAccess.ReadWrite))
2726
{
2827
newDocument.Save(outputStream, FormatType.Docx);
2928
}
3029
}
31-
fileId++;
3230
}
3331
}
3432
}

Word-document/Split-by-section/.NET/Split-by-section/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,20 @@ using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Template.
2424
//Load the template document as stream
2525
using (WordDocument document = new WordDocument(inputStream, FormatType.Docx))
2626
{
27-
int fileId = 1;
2827
//Iterate each section from Word document
29-
foreach (WSection section in document.Sections)
28+
for (int i = 0; i < document.Sections.Count; i++)
3029
{
3130
//Create new Word document
3231
using (WordDocument newDocument = new WordDocument())
3332
{
3433
//Add cloned section into new Word document
35-
newDocument.Sections.Add(section.Clone());
34+
newDocument.Sections.Add(document.Sections[i].Clone());
3635
//Saves the Word document to MemoryStream
37-
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Section") + fileId + ".docx", FileMode.OpenOrCreate, FileAccess.ReadWrite))
36+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Section") + i + ".docx", FileMode.OpenOrCreate, FileAccess.ReadWrite))
3837
{
3938
newDocument.Save(outputStream, FormatType.Docx);
4039
}
4140
}
42-
fileId++;
4341
}
4442
}
4543
}

Word-to-Image-conversion/Convert-Word-to-image/.NET/Convert-Word-to-image/Program.cs

+5-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Program
99
{
1010
static void Main(string[] args)
1111
{
12+
// Open the Word document file stream
1213
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open))
1314
{
1415
//Loads an existing Word document.
@@ -17,20 +18,15 @@ static void Main(string[] args)
1718
//Creates an instance of DocIORenderer.
1819
using (DocIORenderer renderer = new DocIORenderer())
1920
{
20-
//Converts Word document to images.
21+
//Convert the entire Word document to images.
2122
Stream[] imageStreams = wordDocument.RenderAsImages();
22-
int i = 0;
23-
foreach (Stream stream in imageStreams)
23+
for (int i = 0; i < imageStreams.Length; i++)
2424
{
25-
//Resets the stream position.
26-
stream.Position = 0;
27-
//Creates the output image file stream.
25+
//Save the image stream as file.
2826
using (FileStream fileStreamOutput = File.Create(Path.GetFullPath(@"Output/Output_" + i + ".jpeg")))
2927
{
30-
//Copies the converted image stream into created output stream.
31-
stream.CopyTo(fileStreamOutput);
28+
imageStreams[i].CopyTo(fileStreamOutput);
3229
}
33-
i++;
3430
}
3531
}
3632
}

Word-to-PDF-Conversion/Convert-Word-document-to-PDF/.NET/Convert-Word-document-to-PDF/Program.cs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
using System.IO;
1+
using Syncfusion.DocIO;
22
using Syncfusion.DocIO.DLS;
33
using Syncfusion.DocIORenderer;
4-
using Syncfusion.OfficeChart;
54
using Syncfusion.Pdf;
5+
using System.IO;
66

77
namespace Convert_Word_document_to_PDF
88
{
99
class Program
1010
{
1111
static void Main(string[] args)
1212
{
13+
//Open the Word document file stream.
1314
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open))
1415
{
1516
//Loads an existing Word document.
16-
using (WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic))
17+
using (WordDocument wordDocument = new WordDocument(fileStream, FormatType.Automatic))
1718
{
1819
//Creates an instance of DocIORenderer.
1920
using (DocIORenderer renderer = new DocIORenderer())
2021
{
21-
//Sets Chart rendering Options.
22-
renderer.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Jpeg;
2322
//Converts Word document into PDF document.
2423
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
2524
{

Word-to-PDF-Conversion/Convert-Word-document-to-PDF/.NET/Convert-Word-document-to-PDF/README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Step 3: Include the following namespaces in the Program.cs file.
1414
using Syncfusion.DocIO;
1515
using Syncfusion.DocIO.DLS;
1616
using Syncfusion.DocIORenderer;
17-
using Syncfusion.OfficeChart;
1817
using Syncfusion.Pdf;
1918
using System.IO;
2019
```
@@ -25,13 +24,11 @@ Step 4: Add the following code snippet in Program.cs file to convert a Word docu
2524
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open))
2625
{
2726
//Loads an existing Word document.
28-
using (WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic))
27+
using (WordDocument wordDocument = new WordDocument(fileStream, FormatType.Automatic))
2928
{
3029
//Creates an instance of DocIORenderer.
3130
using (DocIORenderer renderer = new DocIORenderer())
3231
{
33-
//Sets Chart rendering Options.
34-
renderer.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Jpeg;
3532
//Converts Word document into PDF document.
3633
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
3734
{

0 commit comments

Comments
 (0)