Skip to content

Commit 6e474b9

Browse files
Updated the content for blog
1 parent 3d362d6 commit 6e474b9

160 files changed

Lines changed: 149507 additions & 421 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Automatic_toc_creation/Automatic_toc_creation/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static void Main(string[] args)
1717

1818
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
1919

20-
//Enable automati TOC creation
20+
//Enable automatic TOC creation
2121
blinkConverterSettings.EnableToc = true;
2222

2323
//Set the style for level 1(H1) items in table of contents
@@ -42,6 +42,7 @@ static void Main(string[] args)
4242
//Save and close the PDF document
4343
document.Save(fileStream);
4444
document.Close(true);
45+
htmlConverter.Close();
4546
}
4647
}
4748
}

Data/html_file.html

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
6+
<head>
7+
<title>Sample HTML File</title>
8+
<style>
9+
.page-break {
10+
page-break-before: always;
11+
}
12+
</style>
13+
</head>
14+
15+
</head>
16+
<body>
17+
<h1>Adventure Work Cycles</h1>
18+
<p>Adventure Works Cycles, the fictitious company on which the
19+
AdventureWorks sample databases are based, is a large, multinational
20+
manufacturing company. The company manufactures and sells metal and
21+
composite bicycles to North American, European and Asian commercial
22+
markets. While its base operation is located in Bothell, Washington with 290
23+
employees, several regional sales teams are located throughout their market
24+
base.
25+
</p>
26+
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
27+
Importadores Neptuno, located in Mexico. Importadores Neptuno
28+
manufactures several critical subcomponents for the Adventure Works
29+
Cycles product line. These subcomponents are shipped to the Bothell
30+
location for final product assembly. In 2001, Importadores Neptuno, became
31+
the sole manufacturer and distributor of the touring bicycle product group.</p>
32+
<div class="page-break"></div>
33+
<h1>Adventure Work Cycles</h1>
34+
<p>Adventure Works Cycles, the fictitious company on which the
35+
AdventureWorks sample databases are based, is a large, multinational
36+
manufacturing company. The company manufactures and sells metal and
37+
composite bicycles to North American, European and Asian commercial
38+
markets. While its base operation is located in Bothell, Washington with 290
39+
employees, several regional sales teams are located throughout their market
40+
base.
41+
</p>
42+
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
43+
Importadores Neptuno, located in Mexico. Importadores Neptuno
44+
manufactures several critical subcomponents for the Adventure Works
45+
Cycles product line. These subcomponents are shipped to the Bothell
46+
location for final product assembly. In 2001, Importadores Neptuno, became
47+
the sole manufacturer and distributor of the touring bicycle product group.</p>
48+
<div class="page-break"></div>
49+
<h1>Adventure Work Cycles</h1>
50+
<p>Adventure Works Cycles, the fictitious company on which the
51+
AdventureWorks sample databases are based, is a large, multinational
52+
manufacturing company. The company manufactures and sells metal and
53+
composite bicycles to North American, European and Asian commercial
54+
markets. While its base operation is located in Bothell, Washington with 290
55+
employees, several regional sales teams are located throughout their market
56+
base.
57+
</p>
58+
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
59+
Importadores Neptuno, located in Mexico. Importadores Neptuno
60+
manufactures several critical subcomponents for the Adventure Works
61+
Cycles product line. These subcomponents are shipped to the Bothell
62+
location for final product assembly. In 2001, Importadores Neptuno, became
63+
the sole manufacturer and distributor of the touring bicycle product group.</p>
64+
<div class="page-break"></div>
65+
<h1>Adventure Work Cycles</h1>
66+
<p>Adventure Works Cycles, the fictitious company on which the
67+
AdventureWorks sample databases are based, is a large, multinational
68+
manufacturing company. The company manufactures and sells metal and
69+
composite bicycles to North American, European and Asian commercial
70+
markets. While its base operation is located in Bothell, Washington with 290
71+
employees, several regional sales teams are located throughout their market
72+
base.
73+
</p>
74+
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
75+
Importadores Neptuno, located in Mexico. Importadores Neptuno
76+
manufactures several critical subcomponents for the Adventure Works
77+
Cycles product line. These subcomponents are shipped to the Bothell
78+
location for final product assembly. In 2001, Importadores Neptuno, became
79+
the sole manufacturer and distributor of the touring bicycle product group.</p>
80+
<div class="page-break"></div>
81+
<h1>Adventure Work Cycles</h1>
82+
<p>Adventure Works Cycles, the fictitious company on which the
83+
AdventureWorks sample databases are based, is a large, multinational
84+
manufacturing company. The company manufactures and sells metal and
85+
composite bicycles to North American, European and Asian commercial
86+
markets. While its base operation is located in Bothell, Washington with 290
87+
employees, several regional sales teams are located throughout their market
88+
base.
89+
</p>
90+
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
91+
Importadores Neptuno, located in Mexico. Importadores Neptuno
92+
manufactures several critical subcomponents for the Adventure Works
93+
Cycles product line. These subcomponents are shipped to the Bothell
94+
location for final product assembly. In 2001, Importadores Neptuno, became
95+
the sole manufacturer and distributor of the touring bicycle product group.</p>
96+
</body>
97+
</html>

HTML_File_To_PDF/HTML_File_To_PDF/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ static void Main(string[] args)
1414
//Convert HTML File to PDF
1515
PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../../../Data/html_file_converter.htm"));
1616

17-
FileStream fileStream = new FileStream("HTML_file_to_PDF.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);
18-
1917
//Save and close the PDF document
20-
document.Save(fileStream);
18+
document.Save("HTML_file_to_PDF.pdf");
2119
document.Close(true);
2220
}
2321
}
Lines changed: 25 additions & 0 deletions
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 16
4+
VisualStudioVersion = 16.0.30907.101
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTML_String_To_PDF", "HTML_String_To_PDF\HTML_String_To_PDF.csproj", "{36522908-58B7-4463-8CE2-A6C82A99AAA1}"
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+
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.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 = {45FEA5BC-8FA5-407B-87D6-F5575B01716B}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Syncfusion.HtmlConverter;
2+
using Syncfusion.Pdf;
3+
4+
5+
namespace HTML_String_To_PDF
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Initialize HTML to PDF converter with Blink rendering engine
12+
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
13+
14+
//Convert HTML File to PDF
15+
PdfDocument document = htmlConverter.Convert("<h1>Hello world</h1>", "");
16+
17+
//Save and close the PDF document
18+
document.Save("HTML-To-PDF.pdf");
19+
document.Close(true);
20+
}
21+
}
22+
}

Headers_and_Footers/Headers_and_Footers/Headers_and_Footers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows" Version="*" />
9+
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" />
1010
</ItemGroup>
1111

1212
</Project>

Headers_and_Footers/Headers_and_Footers/Program.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,26 @@ static void Main(string[] args)
1515
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
1616

1717
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
18+
19+
blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(794, 1123);
20+
1821
//Adding header
1922
blinkConverterSettings.PdfHeader = CreateHeader();
2023
//Adding footer
2124
blinkConverterSettings.PdfFooter = CreateFooter();
2225

23-
//Set the BlinkBinaries folder path
24-
blinkConverterSettings.BlinkPath = @"../../../../../BlinkBinariesWindows/";
25-
2626
//Assign Blink converter settings to HTML converter
2727
htmlConverter.ConverterSettings = blinkConverterSettings;
2828

2929
//Convert HTML File to PDF
30-
PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../../../Data/html_file_converter.htm"));
31-
32-
30+
PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../../../Data/html_file.html"));
3331

3432
FileStream fileStream = new FileStream("Headers_and_Footers.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);
3533

3634
//Save and close the PDF document
3735
document.Save(fileStream);
3836
document.Close(true);
37+
htmlConverter.Close();
3938
}
4039

4140
//Create header for HTML to PDF converter
@@ -54,14 +53,12 @@ public static PdfPageTemplateElement CreateHeader()
5453

5554
SizeF textSize = font.MeasureString(headerText);
5655

57-
string date = DateTime.Now.ToString("dd/M/yyyy");
58-
59-
//Create a text field to draw in header
60-
PdfCompositeField compositeField = new PdfCompositeField(font, brush, headerText);
6156
//Drawing text field in header
62-
compositeField.Draw(header.Graphics, new PointF((bounds.Width - textSize.Width) / 2, 5));
57+
header.Graphics.DrawString(headerText, font, brush, new PointF((bounds.Width - textSize.Width) / 2, 5));
58+
6359
//Drawing date text in header
64-
header.Graphics.DrawString(date, font, brush, new PointF(10, 5));
60+
header.Graphics.DrawString(DateTime.Now.ToString("dd/M/yyyy"), font, brush, new PointF(10, 5));
61+
6562
//Drawing line in header
6663
header.Graphics.DrawLine(PdfPens.Gray, new PointF(0, bounds.Height - 2), new PointF(bounds.Width, bounds.Height - 2));
6764

@@ -97,7 +94,7 @@ public static PdfPageTemplateElement CreateFooter()
9794
//Drawing text field in footer
9895
compositeField.Draw(footer.Graphics, new PointF((bounds.Width - textSize.Width) / 2, 5));
9996
//Drawing page number field in footer
100-
pageNumberField.Draw(footer.Graphics, new PointF((bounds.Width - 70), 5));
97+
pageNumberField.Draw(footer.Graphics, new PointF((bounds.Width - 120), 5));
10198

10299
return footer;
103100
}

Html_form_to_PDF_form/Html_form_to_PDF_form/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static void Main(string[] args)
2727
//Save and close the PDF document
2828
document.Save(fileStream);
2929
document.Close(true);
30+
htmlConverter.Close();
3031
}
3132
}
3233
}
Lines changed: 25 additions & 0 deletions
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.14.36310.24 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Partial_WebPage_To_PDF", "Partial_WebPage_To_PDF\Partial_WebPage_To_PDF.csproj", "{89B6A119-0F0F-485B-AFA7-0C403CC32263}"
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+
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.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 = {83F5CDBC-F457-474F-AE51-A995A021452A}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)