Skip to content

Commit

Permalink
Merge pull request #63 from SyncfusionExamples/864873
Browse files Browse the repository at this point in the history
864873:  Background color missing issue in HTML Header and Footer.
  • Loading branch information
chinnumuniyappan authored Jan 9, 2024
2 parents 44b31b1 + 55872f1 commit be13356
Show file tree
Hide file tree
Showing 3 changed files with 68 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.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
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>
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);

0 comments on commit be13356

Please sign in to comment.