diff --git a/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC.sln b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC.sln new file mode 100644 index 00000000..a1b9ade9 --- /dev/null +++ b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlToPdfWithUnicodeTOC", "HtmlToPdfWithUnicodeTOC\HtmlToPdfWithUnicodeTOC.csproj", "{4AD65462-EECF-4D8A-82C1-8E4127CE70A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4AD65462-EECF-4D8A-82C1-8E4127CE70A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4AD65462-EECF-4D8A-82C1-8E4127CE70A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4AD65462-EECF-4D8A-82C1-8E4127CE70A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4AD65462-EECF-4D8A-82C1-8E4127CE70A3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Data/ARIALUNI.TTF b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Data/ARIALUNI.TTF new file mode 100644 index 00000000..51a18bca Binary files /dev/null and b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Data/ARIALUNI.TTF differ diff --git a/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Data/Input.html b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Data/Input.html new file mode 100644 index 00000000..20dcf2ce --- /dev/null +++ b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Data/Input.html @@ -0,0 +1,62 @@ + + + + + Multilingual Sample Document + + + + +

Sample Document – Beispiel – Пример документа

+ +

Table of Contents – Inhaltsverzeichnis – Содержание

+ + +
+ +

English Section

+

This document demonstrates multilingual content in HTML using UTF-8 encoding. You can mix English, German, and Russian in the same page.

+ +

Deutscher Abschnitt

+

Dieses Dokument zeigt mehrsprachige Inhalte in HTML mit UTF-8-Kodierung. Sie können Englisch, Deutsch und Russisch auf derselben Seite verwenden.

+ + +

Русский раздел

+

Этот документ демонстрирует мультиязычное содержимое в HTML с использованием кодировки UTF-8. Вы можете использовать английский, немецкий и русский языки на одной странице.

+ + + + \ No newline at end of file diff --git a/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/HtmlToPdfWithUnicodeTOC.csproj b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/HtmlToPdfWithUnicodeTOC.csproj new file mode 100644 index 00000000..b6c32751 --- /dev/null +++ b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/HtmlToPdfWithUnicodeTOC.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Program.cs b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Program.cs new file mode 100644 index 00000000..46913283 --- /dev/null +++ b/HTML to PDF/Blink/HtmlToPdfWithUnicodeTOC/.NET/HtmlToPdfWithUnicodeTOC/Program.cs @@ -0,0 +1,45 @@ +using Syncfusion.Drawing; +using Syncfusion.HtmlConverter; +using Syncfusion.Pdf.Graphics; +using Syncfusion.Pdf.HtmlToPdf; +using Syncfusion.Pdf; + +// Initialize the HTML to PDF converter with Blink rendering engine +HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink); + +// Create Blink converter settings +BlinkConverterSettings settings = new BlinkConverterSettings +{ + EnableToc = true +}; +using (FileStream fontStream = new FileStream(Path.GetFullPath(@"Data/ARIALUNI.TTF"), FileMode.Open, FileAccess.Read)) +{ + // Load a Unicode TrueType font from system or custom path + PdfTrueTypeFont unicodeFont = new PdfTrueTypeFont(fontStream, 14); + + // Set the style for level 1 (H1) items in table of contents + HtmlToPdfTocStyle tocStyleH1 = new HtmlToPdfTocStyle + { + Font = unicodeFont, + BackgroundColor = new PdfSolidBrush(new PdfColor(Color.FromArgb(68, 114, 196))), + ForeColor = PdfBrushes.White, + Padding = new PdfPaddings(5, 5, 3, 3) + }; + + // Apply the style to TOC level 1 + settings.Toc.SetItemStyle(1, tocStyleH1); + + // Assign Blink converter settings to HTML converter + htmlConverter.ConverterSettings = settings; + + // Convert HTML to PDF + PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/Input.html")); + + // Save and close the PDF document + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) + { + document.Save(fileStream); + } + //Close the PDF document + document.Close(true); +}