-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
916965 Added custom footer in HTML to PDF.
- Loading branch information
1 parent
500e3d6
commit 761123a
Showing
8 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...-Framework-Footer-Custom-Font/.NET-Framework/HTML-to-PDF-Framework-Footer-Custom-Font.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34723.18 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTML-to-PDF-Framework-Footer-Custom-Font", "HTML-to-PDF-Framework-Footer-Custom-Font\HTML-to-PDF-Framework-Footer-Custom-Font.csproj", "{DFF2E432-36D2-4AF2-8AA5-C715C9CF0773}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DFF2E432-36D2-4AF2-8AA5-C715C9CF0773}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DFF2E432-36D2-4AF2-8AA5-C715C9CF0773}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DFF2E432-36D2-4AF2-8AA5-C715C9CF0773}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DFF2E432-36D2-4AF2-8AA5-C715C9CF0773}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {FB1E6B03-346E-426C-84B6-45CC1A0277B0} | ||
EndGlobalSection | ||
EndGlobal |
6 changes: 6 additions & 0 deletions
6
...ork-Footer-Custom-Font/.NET-Framework/HTML-to-PDF-Framework-Footer-Custom-Font/App.config
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> | ||
</startup> | ||
</configuration> |
Binary file added
BIN
+1.6 MB
...oter-Custom-Font/.NET-Framework/HTML-to-PDF-Framework-Footer-Custom-Font/Data/calibri.ttf
Binary file not shown.
73 changes: 73 additions & 0 deletions
73
.../HTML-to-PDF-Framework-Footer-Custom-Font/HTML-to-PDF-Framework-Footer-Custom-Font.csproj
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,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{DFF2E432-36D2-4AF2-8AA5-C715C9CF0773}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>HTML_to_PDF_Framework_Footer_Custom_Font</RootNamespace> | ||
<AssemblyName>HTML-to-PDF-Framework-Footer-Custom-Font</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.Compression.Base, Version=27.1450.57.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.Compression.Base.27.1.57\lib\net462\Syncfusion.Compression.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.HtmlConverter.Base, Version=27.1450.57.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.HtmlToPdfConverter.WinForms.27.1.57\lib\net462\Syncfusion.HtmlConverter.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.Licensing, Version=27.1450.57.0, Culture=neutral, PublicKeyToken=632609b4d040f6b4, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.Licensing.27.1.57\lib\net462\Syncfusion.Licensing.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Syncfusion.Pdf.Base, Version=27.1400.57.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Syncfusion.Pdf.WinForms.27.1.57\lib\net462\Syncfusion.Pdf.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="..\packages\Syncfusion.HtmlToPdfConverter.WinForms.27.1.57\build\net462\Syncfusion.HtmlToPdfConverter.WinForms.targets" Condition="Exists('..\packages\Syncfusion.HtmlToPdfConverter.WinForms.27.1.57\build\net462\Syncfusion.HtmlToPdfConverter.WinForms.targets')" /> | ||
</Project> |
Empty file.
46 changes: 46 additions & 0 deletions
46
...ork-Footer-Custom-Font/.NET-Framework/HTML-to-PDF-Framework-Footer-Custom-Font/Program.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,46 @@ | ||
using System.Drawing; | ||
using System.IO; | ||
using Syncfusion.HtmlConverter; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
|
||
namespace HTML_to_PDF_Framework_Footer_Custom_Font | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); | ||
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); | ||
//Create font and brush for footer element. | ||
FileStream fontStream = new FileStream(@"Data/calibri.ttf", FileMode.Open, FileAccess.Read); | ||
PdfFont font = new PdfTrueTypeFont(fontStream, 10); | ||
PdfBrush brush = new PdfSolidBrush(Color.Black); | ||
//Create PDF page template element for footer with bounds. | ||
PdfPageTemplateElement footer = new PdfPageTemplateElement(new RectangleF(0, 0, blinkConverterSettings.PdfPageSize.Width, 50)); | ||
//Create page number field. | ||
PdfPageNumberField pageNumber = new PdfPageNumberField(font, PdfBrushes.Black); | ||
//Create page count field. | ||
PdfPageCountField count = new PdfPageCountField(font, PdfBrushes.Black); | ||
//Add the fields in composite fields. | ||
PdfCompositeField compositeField = new PdfCompositeField(font, PdfBrushes.Black, "Page {0} of {1}", pageNumber, count); | ||
//Draw the composite field in footer | ||
compositeField.Draw(footer.Graphics, PointF.Empty); | ||
//Assign the footer element to PdfFooter of Blink converter settings. | ||
blinkConverterSettings.PdfFooter = footer; | ||
//Set Blink viewport size. | ||
blinkConverterSettings.ViewPortSize = new Size(1024, 0); | ||
htmlConverter.ConverterSettings = blinkConverterSettings; | ||
//Convert URL to PDF. | ||
PdfDocument document = htmlConverter.Convert("https://www.google.com/"); | ||
//Create a file stream. | ||
using (FileStream fileStream = new FileStream(@"Output/Output.pdf", FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save a PDF document to the file stream. | ||
document.Save(fileStream); | ||
} | ||
//Close the document. | ||
document.Close(true); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...m-Font/.NET-Framework/HTML-to-PDF-Framework-Footer-Custom-Font/Properties/AssemblyInfo.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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("HTML-to-PDF-Framework-Footer-Custom-Font")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("HTML-to-PDF-Framework-Footer-Custom-Font")] | ||
[assembly: AssemblyCopyright("Copyright © 2024")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("dff2e432-36d2-4af2-8aa5-c715c9cf0773")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
8 changes: 8 additions & 0 deletions
8
...ooter-Custom-Font/.NET-Framework/HTML-to-PDF-Framework-Footer-Custom-Font/packages.config
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,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" /> | ||
<package id="Syncfusion.Compression.Base" version="27.1.57" targetFramework="net462" /> | ||
<package id="Syncfusion.HtmlToPdfConverter.WinForms" version="27.1.57" targetFramework="net462" /> | ||
<package id="Syncfusion.Licensing" version="27.1.57" targetFramework="net462" /> | ||
<package id="Syncfusion.Pdf.WinForms" version="27.1.57" targetFramework="net462" /> | ||
</packages> |