Skip to content

Commit

Permalink
Merge pull request #70 from SyncfusionExamples/875092
Browse files Browse the repository at this point in the history
875092: HTML to PDF converter feature samples.
  • Loading branch information
chinnumuniyappan authored Mar 20, 2024
2 parents 9598dc8 + 861e801 commit 62215cb
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 0 deletions.
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.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accessible PDF", "Accessible PDF\Accessible PDF.csproj", "{9D4BF26B-45EF-428A-8C6F-63E9ECC5039F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9D4BF26B-45EF-428A-8C6F-63E9ECC5039F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D4BF26B-45EF-428A-8C6F-63E9ECC5039F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D4BF26B-45EF-428A-8C6F-63E9ECC5039F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D4BF26B-45EF-428A-8C6F-63E9ECC5039F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1CE4DA91-A9DA-4279-98D3-E2F732A65DC8}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

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

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html>
<head>
</head>
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
</html>

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;

//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
//Initialize the BlinkConverterSettings.
BlinkConverterSettings settings = new BlinkConverterSettings();
//Set true to enable the accessibility tags in PDF generation.
settings.EnableAccessibilityTags = true;
//Assign the BlinkConverterSettings to the ConverterSettings property of HtmlToPdfConverter.
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF.
PdfDocument document = htmlConverter.Convert("file:///D:/PDF-Examples/HTML%20to%20PDF/Blink/Accessible_PDF_In_HTML_to_PDF/.NET/Accessible%20PDF/Input.html");
//Save and close the PDF document.
FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite);
//Save and close the PDF document
document.Save(fileStream);
document.Close(true);
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.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Image_Background_In_HTML_to_PDF", "Image_Background_In_HTML_to_PDF\Image_Background_In_HTML_to_PDF.csproj", "{56A42FB1-CF8D-4137-9E24-B33FFDC7D168}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{56A42FB1-CF8D-4137-9E24-B33FFDC7D168}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56A42FB1-CF8D-4137-9E24-B33FFDC7D168}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56A42FB1-CF8D-4137-9E24-B33FFDC7D168}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56A42FB1-CF8D-4137-9E24-B33FFDC7D168}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AD1CA070-D4C9-4ADD-B6CB-E104FAA503A6}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<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="25.1.35" />
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="25.1.35" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:innovasys xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<meta content="history" name="save" />
<meta name="GENERATOR" content="Innovasys HelpStudio (http://www.innovasys.com)" />
<style>
body { font-family: Georgia }
</style>
</head>
<body id="hsbody">
<table border="0" cellspacing="0" cellpadding="0" class="TitleTable"><tr><td>{{__EntryNumber__}}</td><td>Opening Views</td></tr></table>
<div id="pagebody">
<div id="mainbody">
<p>RealWorld has several core views and a basic browser interface. All core features can be accessed by the Shortcuts window displayed on the left hand side of the RealWorld user interface.</p>

<p>To open, simply click the corresponding node in the shortcuts treeview. If the window is not currently open, or has been closed, it will be opened. If it is already open, then it will be activated.</p>

<p>Clicking a internet shortcut will open/activate the browser window and display the specified page. Only one browser window can be open at any one time.</p>

<p>&nbsp;</p>

<h4>Displaying a list of open windows</h4>

<ul>
<li>Open the <strong>Window</strong> menu. A list of the first 10 open windows will be listed.</li>
</ul>

<p>- or -</p>

<ol>
<li>Open the <strong>Window</strong> menu and click <strong>More Windows</strong>.</li>

<li>The dialog displayed will list all open windows, allowing you to easily view and switch between windows</li>
</ol>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

using Syncfusion.Drawing;
using Syncfusion.HtmlConverter;

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

//Initialize the BlinkConverterSettings
BlinkConverterSettings settings = new BlinkConverterSettings();

//Set the Image Background color.
settings.ImageBackgroundColor = Color.Transparent;

//Assign the BlinkConverterSettings to the ConverterSettings property of HtmlToPdfConverter.
htmlConverter.ConverterSettings = settings;

//Convert HTML to Image
Image image = htmlConverter.ConvertToImage("file:///D:/PDF-Examples/HTML%20to%20PDF/Blink/Image_Background_In_HTML_to_PDF/.NET/Image_Background_In_HTML_to_PDF/Input.html");

//Save the Image.
byte[] imageByte = image.ImageData;

File.WriteAllBytes("Output.png", imageByte);


0 comments on commit 62215cb

Please sign in to comment.