-
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 #109 from SyncfusionExamples/916962
916962 How to add other languages like Arabic beyond English for TOC while performing HTML to PDF conversion in .NET sample
- Loading branch information
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
HTML to PDF/Blink/HTML-to-PDF-TOC-Arabic-Text/.NET/HTML-to-PDF-TOC-Arabic-Text.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-TOC-Arabic-Text", "HTML-to-PDF-TOC-Arabic-Text\HTML-to-PDF-TOC-Arabic-Text.csproj", "{83D3E7AB-E207-4347-A023-94BAD363D60D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{83D3E7AB-E207-4347-A023-94BAD363D60D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{83D3E7AB-E207-4347-A023-94BAD363D60D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{83D3E7AB-E207-4347-A023-94BAD363D60D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{83D3E7AB-E207-4347-A023-94BAD363D60D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F9754656-D265-4374-9538-9B1BE77201C5} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+22.2 MB
...nk/HTML-to-PDF-TOC-Arabic-Text/.NET/HTML-to-PDF-TOC-Arabic-Text/Data/arial-unicode-ms.ttf
Binary file not shown.
44 changes: 44 additions & 0 deletions
44
...o PDF/Blink/HTML-to-PDF-TOC-Arabic-Text/.NET/HTML-to-PDF-TOC-Arabic-Text/Data/input1.html
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,44 @@ | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<style> | ||
body { | ||
font-family: 'Arial Unicode MS', sans-serif; | ||
text-align: left; | ||
font-size: large; | ||
padding-right: 5px; | ||
direction: rtl; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<h1>سينكفيوجن</h1> | ||
|
||
<h2>مقدمة</h2> | ||
سينكفيوجن هي الشريك التكنولوجي المفضل للمؤسسات في تطوير البرمجيات، حيث تقدم مجموعة واسعة من الأدوات للتحكم في الويب، والمحمول، وسطح المكتب بالإضافة إلى نهج موجه نحو الخدمة طوال دورة حياة التطبيق. | ||
|
||
<h2>المنتجات</h2> | ||
<h4>الويب</h4> | ||
أشمل مجموعة لتطوير الويب المؤسسي. | ||
<h4>سطح المكتب</h4> | ||
مجموعة شاملة من أكثر من 115 مكونًا بما في ذلك أسرع مكونات الرسم البياني والشبكة. | ||
<h4>المحمول</h4> | ||
مجموعة شاملة من المكونات لـ Xamarin.iOS و Xamarin.Android و Xamarin.Forms بما في ذلك أسرع رسم بياني وشبكة. | ||
|
||
<h2>الاستشارات</h2> | ||
نحن قادرون على بناء تطبيقات الويب، والمحمول، وسطح المكتب بشكل أفضل وأسرع من أي شخص آخر لأننا نبني على مجموعة مكوناتنا وأطر عملنا الحائزة على جوائز، مما يوفر لك الوقت والمال. | ||
|
||
<h2>الشركة</h2> | ||
<h4>من نحن</h4> | ||
سينكفيوجن رسخت نفسها كشريك موثوق به عالميًا للاستخدام في التطبيقات المهمة. تأسست في عام 2001 ويقع مقرها الرئيسي في منطقة ريسيرش تراينجل بارك، نورث كارولاينا. لدى سينكفيوجن أكثر من 12,000 عميل، بما في ذلك المؤسسات المالية الكبيرة، وشركات فورتشن 100، وشركات الاستشارات التقنية العالمية. | ||
<h4>اتصل بنا</h4> | ||
مكتب موريسفيل | ||
المقر الرئيسي للشركة | ||
2501 طريق المطار الجوي | ||
الطابق 200 | ||
موريسفيل، نورث كارولاينا 27560 | ||
الولايات المتحدة الأمريكية | ||
|
||
</body> | ||
</html> |
15 changes: 15 additions & 0 deletions
15
...o-PDF-TOC-Arabic-Text/.NET/HTML-to-PDF-TOC-Arabic-Text/HTML-to-PDF-TOC-Arabic-Text.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>net8.0</TargetFramework> | ||
<RootNamespace>HTML_to_PDF_TOC_Arabic_Text</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Empty file.
38 changes: 38 additions & 0 deletions
38
HTML to PDF/Blink/HTML-to-PDF-TOC-Arabic-Text/.NET/HTML-to-PDF-TOC-Arabic-Text/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,38 @@ | ||
using Syncfusion.Drawing; | ||
using Syncfusion.HtmlConverter; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Pdf.HtmlToPdf; | ||
|
||
//Initialize the HTML to PDF converter. | ||
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); | ||
//Initialize blink converter settings. | ||
BlinkConverterSettings settings = new BlinkConverterSettings(); | ||
//Set enable table of contents. | ||
settings.EnableToc = true; | ||
//Set the style for level 1(H1) items in table of contents. | ||
HtmlToPdfTocStyle tocstyleH1 = new HtmlToPdfTocStyle(); | ||
// Load the Arabic font from a file | ||
PdfFont arabicFont = new PdfTrueTypeFont(@"Data/arial-unicode-ms.ttf", 10, PdfFontStyle.Regular); | ||
// Set the TOC style with the Arabic font | ||
tocstyleH1.Font = arabicFont; | ||
//tocstyleH1.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 10, PdfFontStyle.Regular); | ||
tocstyleH1.BackgroundColor = new PdfSolidBrush(new PdfColor(Color.FromArgb(68, 114, 196))); | ||
tocstyleH1.ForeColor = PdfBrushes.White; | ||
tocstyleH1.Padding = new PdfPaddings(5, 5, 3, 3); | ||
settings.Toc.SetItemStyle(1, tocstyleH1); | ||
settings.Toc.SetItemStyle(2, tocstyleH1); | ||
settings.Toc.SetItemStyle(3, tocstyleH1); | ||
settings.Toc.SetItemStyle(4, tocstyleH1); | ||
//Assign Blink converter settings to HTML converter. | ||
htmlConverter.ConverterSettings = settings; | ||
//Convert HTML to PDF document. | ||
PdfDocument document = htmlConverter.Convert(Path.GetFullPath(@"Data/input1.html")); | ||
//Create file stream to save the PDF document. | ||
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/HTML-to-PDF.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document | ||
document.Save(fileStream); | ||
} | ||
//Close the PDF document | ||
document.Close(true); |