-
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.
Merge pull request #63 from SyncfusionExamples/864873
864873: Background color missing issue in HTML Header and Footer.
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
HTML to PDF/Blink/HTML-Footer-Background-Colour/.NET/HTML-Footer-Background-Colour.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.7.34202.233 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTML-Footer-Background-Colour", "HTML-Footer-Background-Colour\HTML-Footer-Background-Colour.csproj", "{B333B641-9B92-4381-B84B-54F54DDED5B2}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B333B641-9B92-4381-B84B-54F54DDED5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B333B641-9B92-4381-B84B-54F54DDED5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B333B641-9B92-4381-B84B-54F54DDED5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B333B641-9B92-4381-B84B-54F54DDED5B2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {846438BB-6220-4399-BF59-E0AC706E8C52} | ||
EndGlobalSection | ||
EndGlobal |
15 changes: 15 additions & 0 deletions
15
...Background-Colour/.NET/HTML-Footer-Background-Colour/HTML-Footer-Background-Colour.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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>HTML_Footer_Background_Colour</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="23.2.7" /> | ||
</ItemGroup> | ||
|
||
</Project> |
28 changes: 28 additions & 0 deletions
28
... to PDF/Blink/HTML-Footer-Background-Colour/.NET/HTML-Footer-Background-Colour/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,28 @@ | ||
//Initialize HTML to PDF converter. | ||
using Syncfusion.HtmlConverter; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Drawing; | ||
|
||
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); | ||
//Initialize blink converter settings. | ||
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); | ||
//Set the Blink viewport size. | ||
blinkConverterSettings.ViewPortSize = new Size(1280, 0); | ||
//Set the html margin-top value based on the html header height and margin-top value. | ||
blinkConverterSettings.Margin.Top = 70; | ||
//Set the html margin-bottom value based on the html footer height and margin-bottom value. | ||
blinkConverterSettings.Margin.Bottom = 40; | ||
//Set the custom HTML header to add at the top of each page. | ||
blinkConverterSettings.HtmlHeader = " <div style=\"background-color: blue; -webkit-print-color-adjust: exact; margin-left: 40px; font-size: 10px;\">HTML Header</div>"; | ||
//Set the custom HTML footer to add at the bottom of each page. | ||
blinkConverterSettings.HtmlFooter = " <div style=\"background-color: blue; -webkit-print-color-adjust: exact;margin-left: 40px; font-size: 10px;\">HTML Footer</div>"; | ||
//Assign Blink converter settings to the HTML converter. | ||
htmlConverter.ConverterSettings = blinkConverterSettings; | ||
//Convert the URL to a PDF document. | ||
PdfDocument document = htmlConverter.Convert("<div>Hello World</div>",string.Empty); | ||
|
||
//Create a filestream. | ||
FileStream fileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite); | ||
//Save and close a PDF document. | ||
document.Save(fileStream); | ||
document.Close(true); |