Table of Contents

Class HtmlToPdfTocStyle

Namespace
Syncfusion.Pdf.HtmlToPdf
Assembly
Syncfusion.Pdf.Portable.dll

This class contains the necessary properties to apply style in the automatic creation of a table of contents in a PDF document.

public class HtmlToPdfTocStyle
Inheritance
HtmlToPdfTocStyle
Inherited Members

Examples

//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Create a new instance for webkit converter settings.
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Enable toc.
settings.EnableToc = true;
//Create a new instance for HTML to PDF toc.
HtmlToPdfToc toc = new HtmlToPdfToc();
//Set title.
toc.Title = "HTML to PDF";
//Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center;
//Create new HTML to PDF Toc Style.
HtmlToPdfTocStyle style = new HtmlToPdfTocStyle();
//Set background color.
style.BackgroundColor = new PdfSolidBrush(Color.LightCyan);
//Set font.
style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Set fore color.
style.ForeColor = new PdfSolidBrush(Color.Red);
//Set paddings.
style.Padding = new PdfPaddings(5, 5, 5, 5);
//Set toc style.
toc.TitleStyle = style;
//Set toc to webkit settings.
settings.Toc = toc;
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework");
//Save and close the PDF document 
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter 
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Create a new instance for webkit converter settings.
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Enable toc.
settings.EnableToc = True
'Create a new instance for HTML to PDF toc.
Dim toc As New HtmlToPdfToc()
'Set title.
toc.Title = "HTML to PDF"
'Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center
'Create new HTML to PDF Toc Style.
Dim style As New HtmlToPdfTocStyle()
'Set background color.
style.BackgroundColor = New PdfSolidBrush(Color.LightCyan)
'Set font.
style.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Set fore color.
style.ForeColor = New PdfSolidBrush(Color.Red)
'Set paddings.
style.Padding = New PdfPaddings(5, 5, 5, 5)
'Set toc style.
toc.TitleStyle = style
'Set toc to webkit settings.
settings.Toc = toc
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework")
'Save and close the PDF document 
document.Save("Output.pdf")
document.Close(True)

Constructors

HtmlToPdfTocStyle()

public HtmlToPdfTocStyle()

Properties

BackgroundColor

Gets or sets the back ground color

public PdfBrush BackgroundColor { get; set; }

Property Value

PdfBrush

Examples

//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Create a new instance for webkit converter settings.
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Enable toc.
settings.EnableToc = true;
//Create a new instance for HTML to PDF toc.
HtmlToPdfToc toc = new HtmlToPdfToc();
//Set title.
toc.Title = "HTML to PDF";
//Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center;
//Create new HTML to PDF Toc Style.
HtmlToPdfTocStyle style = new HtmlToPdfTocStyle();
//Set background color.
style.BackgroundColor = new PdfSolidBrush(Color.LightCyan);
//Set font.
style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Set fore color.
style.ForeColor = new PdfSolidBrush(Color.Red);
//Set paddings.
style.Padding = new PdfPaddings(5, 5, 5, 5);
//Set toc style.
toc.TitleStyle = style;
//Set toc to webkit settings.
settings.Toc = toc;
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework");
//Save and close the PDF document 
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter 
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Create a new instance for webkit converter settings.
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Enable toc.
settings.EnableToc = True
'Create a new instance for HTML to PDF toc.
Dim toc As New HtmlToPdfToc()
'Set title.
toc.Title = "HTML to PDF"
'Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center
'Create new HTML to PDF Toc Style.
Dim style As New HtmlToPdfTocStyle()
'Set background color.
style.BackgroundColor = New PdfSolidBrush(Color.LightCyan)
'Set font.
style.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Set fore color.
style.ForeColor = New PdfSolidBrush(Color.Red)
'Set paddings.
style.Padding = New PdfPaddings(5, 5, 5, 5)
'Set toc style.
toc.TitleStyle = style
'Set toc to webkit settings.
settings.Toc = toc
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework")
'Save and close the PDF document 
document.Save("Output.pdf")
document.Close(True)

Font

Gets or sets the font

public PdfFont Font { get; set; }

Property Value

PdfFont

Examples

//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Create a new instance for webkit converter settings.
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Enable toc.
settings.EnableToc = true;
//Create a new instance for HTML to PDF toc.
HtmlToPdfToc toc = new HtmlToPdfToc();
//Set title.
toc.Title = "HTML to PDF";
//Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center;
//Create new HTML to PDF Toc Style.
HtmlToPdfTocStyle style = new HtmlToPdfTocStyle();
//Set background color.
style.BackgroundColor = new PdfSolidBrush(Color.LightCyan);
//Set font.
style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Set fore color.
style.ForeColor = new PdfSolidBrush(Color.Red);
//Set paddings.
style.Padding = new PdfPaddings(5, 5, 5, 5);
//Set toc style.
toc.TitleStyle = style;
//Set toc to webkit settings.
settings.Toc = toc;
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework");
//Save and close the PDF document 
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter 
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Create a new instance for webkit converter settings.
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Enable toc.
settings.EnableToc = True
'Create a new instance for HTML to PDF toc.
Dim toc As New HtmlToPdfToc()
'Set title.
toc.Title = "HTML to PDF"
'Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center
'Create new HTML to PDF Toc Style.
Dim style As New HtmlToPdfTocStyle()
'Set background color.
style.BackgroundColor = New PdfSolidBrush(Color.LightCyan)
'Set font.
style.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Set fore color.
style.ForeColor = New PdfSolidBrush(Color.Red)
'Set paddings.
style.Padding = New PdfPaddings(5, 5, 5, 5)
'Set toc style.
toc.TitleStyle = style
'Set toc to webkit settings.
settings.Toc = toc
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework")
'Save and close the PDF document 
document.Save("Output.pdf")
document.Close(True)

ForeColor

Gets or sets the fore color

public PdfBrush ForeColor { get; set; }

Property Value

PdfBrush

Examples

//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Create a new instance for webkit converter settings.
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Enable toc.
settings.EnableToc = true;
//Create a new instance for HTML to PDF toc.
HtmlToPdfToc toc = new HtmlToPdfToc();
//Set title.
toc.Title = "HTML to PDF";
//Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center;
//Create new HTML to PDF Toc Style.
HtmlToPdfTocStyle style = new HtmlToPdfTocStyle();
//Set background color.
style.BackgroundColor = new PdfSolidBrush(Color.LightCyan);
//Set font.
style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Set fore color.
style.ForeColor = new PdfSolidBrush(Color.Red);
//Set paddings.
style.Padding = new PdfPaddings(5, 5, 5, 5);
//Set toc style.
toc.TitleStyle = style;
//Set toc to webkit settings.
settings.Toc = toc;
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework");
//Save and close the PDF document 
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter 
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Create a new instance for webkit converter settings.
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Enable toc.
settings.EnableToc = True
'Create a new instance for HTML to PDF toc.
Dim toc As New HtmlToPdfToc()
'Set title.
toc.Title = "HTML to PDF"
'Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center
'Create new HTML to PDF Toc Style.
Dim style As New HtmlToPdfTocStyle()
'Set background color.
style.BackgroundColor = New PdfSolidBrush(Color.LightCyan)
'Set font.
style.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Set fore color.
style.ForeColor = New PdfSolidBrush(Color.Red)
'Set paddings.
style.Padding = New PdfPaddings(5, 5, 5, 5)
'Set toc style.
toc.TitleStyle = style
'Set toc to webkit settings.
settings.Toc = toc
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework")
'Save and close the PDF document 
document.Save("Output.pdf")
document.Close(True)

Padding

Gets or sets the padding

public PdfPaddings Padding { get; set; }

Property Value

PdfPaddings

Examples

//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
//Create a new instance for webkit converter settings.
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = @"/QtBinaries/";
//Enable toc.
settings.EnableToc = true;
//Create a new instance for HTML to PDF toc.
HtmlToPdfToc toc = new HtmlToPdfToc();
//Set title.
toc.Title = "HTML to PDF";
//Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center;
//Create new HTML to PDF Toc Style.
HtmlToPdfTocStyle style = new HtmlToPdfTocStyle();
//Set background color.
style.BackgroundColor = new PdfSolidBrush(Color.LightCyan);
//Set font.
style.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
//Set fore color.
style.ForeColor = new PdfSolidBrush(Color.Red);
//Set paddings.
style.Padding = new PdfPaddings(5, 5, 5, 5);
//Set toc style.
toc.TitleStyle = style;
//Set toc to webkit settings.
settings.Toc = toc;
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework");
//Save and close the PDF document 
document.Save("Output.pdf");
document.Close(true);
'Initialize HTML to PDF converter 
Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.WebKit)
'Create a new instance for webkit converter settings.
Dim settings As New WebKitConverterSettings()
'Set WebKit path
settings.WebKitPath = "/QtBinaries/"
'Enable toc.
settings.EnableToc = True
'Create a new instance for HTML to PDF toc.
Dim toc As New HtmlToPdfToc()
'Set title.
toc.Title = "HTML to PDF"
'Set title alignment.
toc.TitleAlignment = PdfTextAlignment.Center
'Create new HTML to PDF Toc Style.
Dim style As New HtmlToPdfTocStyle()
'Set background color.
style.BackgroundColor = New PdfSolidBrush(Color.LightCyan)
'Set font.
style.Font = New PdfStandardFont(PdfFontFamily.Helvetica, 12)
'Set fore color.
style.ForeColor = New PdfSolidBrush(Color.Red)
'Set paddings.
style.Padding = New PdfPaddings(5, 5, 5, 5)
'Set toc style.
toc.TitleStyle = style
'Set toc to webkit settings.
settings.Toc = toc
'Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("https://en.wikipedia.org/wiki/.NET_Framework")
'Save and close the PDF document 
document.Save("Output.pdf")
document.Close(True)