Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Automatic_toc_creation/Automatic_toc_creation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void Main(string[] args)

BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

//Enable automati TOC creation
//Enable automatic TOC creation
blinkConverterSettings.EnableToc = true;

//Set the style for level 1(H1) items in table of contents
Expand All @@ -42,6 +42,7 @@ static void Main(string[] args)
//Save and close the PDF document
document.Save(fileStream);
document.Close(true);
htmlConverter.Close();
}
}
}
97 changes: 97 additions & 0 deletions Data/html_file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

<!DOCTYPE html>
<html>
<head>

<head>
<title>Sample HTML File</title>
<style>
.page-break {
page-break-before: always;
}
</style>
</head>

</head>
<body>
<h1>Adventure Work Cycles</h1>
<p>Adventure Works Cycles, the fictitious company on which the
AdventureWorks sample databases are based, is a large, multinational
manufacturing company. The company manufactures and sells metal and
composite bicycles to North American, European and Asian commercial
markets. While its base operation is located in Bothell, Washington with 290
employees, several regional sales teams are located throughout their market
base.
</p>
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
Importadores Neptuno, located in Mexico. Importadores Neptuno
manufactures several critical subcomponents for the Adventure Works
Cycles product line. These subcomponents are shipped to the Bothell
location for final product assembly. In 2001, Importadores Neptuno, became
the sole manufacturer and distributor of the touring bicycle product group.</p>
<div class="page-break"></div>
<h1>Adventure Work Cycles</h1>
<p>Adventure Works Cycles, the fictitious company on which the
AdventureWorks sample databases are based, is a large, multinational
manufacturing company. The company manufactures and sells metal and
composite bicycles to North American, European and Asian commercial
markets. While its base operation is located in Bothell, Washington with 290
employees, several regional sales teams are located throughout their market
base.
</p>
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
Importadores Neptuno, located in Mexico. Importadores Neptuno
manufactures several critical subcomponents for the Adventure Works
Cycles product line. These subcomponents are shipped to the Bothell
location for final product assembly. In 2001, Importadores Neptuno, became
the sole manufacturer and distributor of the touring bicycle product group.</p>
<div class="page-break"></div>
<h1>Adventure Work Cycles</h1>
<p>Adventure Works Cycles, the fictitious company on which the
AdventureWorks sample databases are based, is a large, multinational
manufacturing company. The company manufactures and sells metal and
composite bicycles to North American, European and Asian commercial
markets. While its base operation is located in Bothell, Washington with 290
employees, several regional sales teams are located throughout their market
base.
</p>
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
Importadores Neptuno, located in Mexico. Importadores Neptuno
manufactures several critical subcomponents for the Adventure Works
Cycles product line. These subcomponents are shipped to the Bothell
location for final product assembly. In 2001, Importadores Neptuno, became
the sole manufacturer and distributor of the touring bicycle product group.</p>
<div class="page-break"></div>
<h1>Adventure Work Cycles</h1>
<p>Adventure Works Cycles, the fictitious company on which the
AdventureWorks sample databases are based, is a large, multinational
manufacturing company. The company manufactures and sells metal and
composite bicycles to North American, European and Asian commercial
markets. While its base operation is located in Bothell, Washington with 290
employees, several regional sales teams are located throughout their market
base.
</p>
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
Importadores Neptuno, located in Mexico. Importadores Neptuno
manufactures several critical subcomponents for the Adventure Works
Cycles product line. These subcomponents are shipped to the Bothell
location for final product assembly. In 2001, Importadores Neptuno, became
the sole manufacturer and distributor of the touring bicycle product group.</p>
<div class="page-break"></div>
<h1>Adventure Work Cycles</h1>
<p>Adventure Works Cycles, the fictitious company on which the
AdventureWorks sample databases are based, is a large, multinational
manufacturing company. The company manufactures and sells metal and
composite bicycles to North American, European and Asian commercial
markets. While its base operation is located in Bothell, Washington with 290
employees, several regional sales teams are located throughout their market
base.
</p>
<p>In 2000, Adventure Works Cycles bought a small manufacturing plant,
Importadores Neptuno, located in Mexico. Importadores Neptuno
manufactures several critical subcomponents for the Adventure Works
Cycles product line. These subcomponents are shipped to the Bothell
location for final product assembly. In 2001, Importadores Neptuno, became
the sole manufacturer and distributor of the touring bicycle product group.</p>
</body>
</html>
4 changes: 1 addition & 3 deletions HTML_File_To_PDF/HTML_File_To_PDF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ static void Main(string[] args)
//Convert HTML File to PDF
PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../../../Data/html_file_converter.htm"));

FileStream fileStream = new FileStream("HTML_file_to_PDF.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
document.Save("HTML_file_to_PDF.pdf");
document.Close(true);
}
}
Expand Down
25 changes: 25 additions & 0 deletions HTML_String_To_PDF/HTML_String_To_PDF.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTML_String_To_PDF", "HTML_String_To_PDF\HTML_String_To_PDF.csproj", "{36522908-58B7-4463-8CE2-A6C82A99AAA1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36522908-58B7-4463-8CE2-A6C82A99AAA1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {45FEA5BC-8FA5-407B-87D6-F5575B01716B}
EndGlobalSection
EndGlobal
12 changes: 12 additions & 0 deletions HTML_String_To_PDF/HTML_String_To_PDF/HTML_String_To_PDF.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions HTML_String_To_PDF/HTML_String_To_PDF/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;


namespace HTML_String_To_PDF
{
class Program
{
static void Main(string[] args)
{
//Initialize HTML to PDF converter with Blink rendering engine
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

//Convert HTML File to PDF
PdfDocument document = htmlConverter.Convert("<h1>Hello world</h1>", "");

//Save and close the PDF document
document.Save("HTML-To-PDF.pdf");
document.Close(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Blink.Net.Core.Windows" Version="*" />
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" />
</ItemGroup>

</Project>
23 changes: 10 additions & 13 deletions Headers_and_Footers/Headers_and_Footers/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@ static void Main(string[] args)
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);

BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(794, 1123);

//Adding header
blinkConverterSettings.PdfHeader = CreateHeader();
//Adding footer
blinkConverterSettings.PdfFooter = CreateFooter();

//Set the BlinkBinaries folder path
blinkConverterSettings.BlinkPath = @"../../../../../BlinkBinariesWindows/";

//Assign Blink converter settings to HTML converter
htmlConverter.ConverterSettings = blinkConverterSettings;

//Convert HTML File to PDF
PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../../../Data/html_file_converter.htm"));


PdfDocument document = htmlConverter.Convert(Path.GetFullPath("../../../../../Data/html_file.html"));

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

//Save and close the PDF document
document.Save(fileStream);
document.Close(true);
htmlConverter.Close();
}

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

SizeF textSize = font.MeasureString(headerText);

string date = DateTime.Now.ToString("dd/M/yyyy");

//Create a text field to draw in header
PdfCompositeField compositeField = new PdfCompositeField(font, brush, headerText);
//Drawing text field in header
compositeField.Draw(header.Graphics, new PointF((bounds.Width - textSize.Width) / 2, 5));
header.Graphics.DrawString(headerText, font, brush, new PointF((bounds.Width - textSize.Width) / 2, 5));

//Drawing date text in header
header.Graphics.DrawString(date, font, brush, new PointF(10, 5));
header.Graphics.DrawString(DateTime.Now.ToString("dd/M/yyyy"), font, brush, new PointF(10, 5));

//Drawing line in header
header.Graphics.DrawLine(PdfPens.Gray, new PointF(0, bounds.Height - 2), new PointF(bounds.Width, bounds.Height - 2));

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

return footer;
}
Expand Down
1 change: 1 addition & 0 deletions Html_form_to_PDF_form/Html_form_to_PDF_form/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static void Main(string[] args)
//Save and close the PDF document
document.Save(fileStream);
document.Close(true);
htmlConverter.Close();
}
}
}
25 changes: 25 additions & 0 deletions Partial_WebPage_To_PDF/Partial_WebPage_To_PDF.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36310.24 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Partial_WebPage_To_PDF", "Partial_WebPage_To_PDF\Partial_WebPage_To_PDF.csproj", "{89B6A119-0F0F-485B-AFA7-0C403CC32263}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89B6A119-0F0F-485B-AFA7-0C403CC32263}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83F5CDBC-F457-474F-AE51-A995A021452A}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions Partial_WebPage_To_PDF/Partial_WebPage_To_PDF/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;

//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

htmlConverter.ConverterSettings = new BlinkConverterSettings() { ViewPortSize = new Syncfusion.Drawing.Size(1280, 1024) };

//Convert URL to PDF document.
PdfDocument document = htmlConverter.ConvertPartialHtml(File.ReadAllText("../../../../../Data/partialdemo.html"), "", "details");

//Save and closes the PDF document.
document.Save("Partial-webpage-to-PDF.pdf");
document.Close(true);
htmlConverter.Close();

This file was deleted.

4 changes: 1 addition & 3 deletions URL_to_PDF/URL_to_PDF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ static void Main(string[] args)
//Convert existing URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com/");

FileStream fileStream = new FileStream("URL_to_PDF.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);

//Save and close the PDF document
document.Save(fileStream);
document.Save("URL_to_PDF.pdf");
document.Close(true);
}
}
Expand Down
16 changes: 8 additions & 8 deletions Web_MVC_to_PDF/Web_MVC_to_PDF.sln
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
# Visual Studio Version 17
VisualStudioVersion = 17.14.36310.24 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web_MVC_to_PDF", "Web_MVC_to_PDF\Web_MVC_to_PDF.csproj", "{D3F23345-63ED-4FCB-BB9F-75577B9C6B79}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web_MVC_to_PDF", "Web_MVC_to_PDF\Web_MVC_to_PDF.csproj", "{3A6EF107-8239-472A-A693-C40C8B0155ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D3F23345-63ED-4FCB-BB9F-75577B9C6B79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3F23345-63ED-4FCB-BB9F-75577B9C6B79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3F23345-63ED-4FCB-BB9F-75577B9C6B79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3F23345-63ED-4FCB-BB9F-75577B9C6B79}.Release|Any CPU.Build.0 = Release|Any CPU
{3A6EF107-8239-472A-A693-C40C8B0155ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A6EF107-8239-472A-A693-C40C8B0155ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A6EF107-8239-472A-A693-C40C8B0155ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A6EF107-8239-472A-A693-C40C8B0155ED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A6E0D5E8-9092-453D-A6C1-94530EC21F6F}
SolutionGuid = {DA86649F-B655-44E4-AF29-4A9A2C930E58}
EndGlobalSection
EndGlobal
Loading