We are using Aspose.PDF version 24.1.0 to convert an HTML file to PDF. While the general conversion works, we are facing a critical issue with the display of Arabic text. Specifically, there are large spaces between Arabic words, which severely affects the readability and formatting of the content.
We have tried multiple solutions, including applying custom CSS styles to control the spacing, but none of them resolved the issue.
The HTML content contains both Arabic and English sections, and the problem is only observed in the Arabic text. The English content appears correctly. Additionally, we are using a web font (Amiri) for the Arabic text, but even with standard fonts like Arial, there was an issue with displaying some character’s like (لا) it wasn’t displayed properly.
Here is you will find a screen shoot for specific part that we have a problem in it in the generated pdf file.
image.png (40.6 KB)
also i will attach the html content that we pass it to aspose
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PDF Generation</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Arial', sans-serif;
font-size: 15px;
margin: 0;
padding: 0;
}
.header {
text-align: center;
padding: 10px 20px;
}
.header img {
max-width: 200px;
}
.content {
padding: 20px;
}
.footer {
text-align: center;
margin-top: 20px;
padding: 10px;
font-size: 12px;
page-break-inside: avoid;
}
.footer table {
border-top: 2px solid #dfdec3;
width: 100%;
margin-top: 10px;
border-collapse: collapse;
}
.footer td {
padding: 5px;
font-size: 10px;
border: none;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
table-layout: fixed; /* Prevents column width issues */
}
th, td {
padding: 8px;
border: 1px solid #000;
text-align: right;
word-wrap: break-word; /* Ensures content wraps within the cell */
overflow-wrap: break-word; /* Prevents overflow */
}
.rtl {
direction: rtl !important;
text-align: right !important;
font-family: 'Amiri', 'DejaVu Sans', 'Noto Sans Arabic', sans-serif; /* Arabic font */
font-size: 12px;
word-spacing: -2px;
}
.align-left {
text-align: left;
}
.english {
direction: ltr;
text-align: left;
font-family: 'Arial', sans-serif;
}
.page {
page-break-after: always;
}
.note {
font-size: 12px;
margin-top: 10px;
}
.logo {
max-width: 200px;
margin: auto;
}
</style>
</head>
<body>
<!-- Arabic Content -->
<div class="header">
<h3>كتاب إثبات تسجيل ملكية نطاق</h3>
</div>
<div class="page">
<div class="content rtl">
<p>لمن يهمه الأمر,</p>
<p>بناء على طلب المسجل/المنسق الإداري الحالي تم إصدار هذا الكتاب إلكترونيًا من منصة ** ** وهي أحد منتجات ** (**)، كوكيل تسجيل نطاق ** مرخص من هيئة الاتصالات والفضاء والتقنية (**) للنطاقات المحلية (**). نفيدكم علماً بأن النطاق المذكور أدناه مسجل رسميًا لدينا حسب البيانات التالية:</p>
<table>
<tr>
<th>اسم النطاق</th>
<td>{{DomainName}}</td>
</tr>
<tr>
<th>تاريخ التسجيل للنطاق</th>
<td>{{ActivationDate}}</td>
</tr>
<tr>
<th>تاريخ انتهاء صلاحية التسجيل للنطاق</th>
<td>{{ExpiryDate}}</td>
</tr>
<tr>
<th>اسم الجهة</th>
<td>{{CompanyName}}</td>
</tr>
<tr>
<th>اسم المسجل</th>
<td>{{RegistrantFullName}}</td>
</tr>
<tr>
<th>البريد الإلكتروني للمسجل</th>
<td>{{RegistrantEmail}}</td>
</tr>
<tr>
<th>اسم المنسق الإداري</th>
<td>{{AdminFullName}}</td>
</tr>
<tr>
<th>البريد الإلكتروني للمنسق الإداري</th>
<td>{{AdminEmail}}</td>
</tr>
</table>
<p class="note"><strong>و بناء عليه حرر هذا الكتاب إلكترونيًا بتاريخ: {{CurrentDate}}</strong></p>
<p class="note"><strong>ملاحظة:</strong> تجدون على موقع المركز ال** لمعلومات الشبكة عبر الرابط التالي بعض البيانات العامة المعلنة والمحدثة عن النطاق: </p>
</div>
</div>
<!-- English Content (same as before) -->
<div class="page">
<div class="header">
<h3>Domain Ownership Registration Letter</h3>
</div>
<div class="content english">
<p>To whom it may concern,</p>
<p style="font-size: 13px;">At the request of the current domain registrant/administrative coordinator, this letter was issued electronically from the ** ** platform, a product of ** (**), as a licensed ** domain registration agent by the Communications and Space Technology Commission (**) for local domains (**). The domain mentioned below is officially registered with us according to the following details:</p>
<table>
<tr>
<th style="text-align: left;">Domain Name</th>
<td class="align-left">{{DomainName}}</td>
</tr>
<tr>
<th style="text-align: left;">Registration Date</th>
<td class="align-left">{{ActivationDate}}</td>
</tr>
<tr>
<th style="text-align: left;">Expiry Date</th>
<td class="align-left">{{ExpiryDate}}</td>
</tr>
<tr>
<th style="text-align: left;">Entity Name</th>
<td class="align-left">{{CompanyName}}</td>
</tr>
<tr>
<th style="text-align: left;">Registrant Name</th>
<td class="align-left">{{RegistrantFullName}}</td>
</tr>
<tr>
<th style="text-align: left;">Registrant Email</th>
<td class="align-left">{{RegistrantEmail}}</td>
</tr>
<tr>
<th style="text-align: left;">Administrative Coordinator Name</th>
<td class="align-left">{{AdminFullName}}</td>
</tr>
<tr>
<th style="text-align: left;">Administrative Coordinator Email</th>
<td class="align-left">{{AdminEmail}}</td>
</tr>
</table>
<p class="note"><strong>Accordingly, this letter was issued electronically on: {{CurrentDate}}</strong></p>
<p class="note"><strong>Note:</strong> You can find publicly available and updated domain information on the ** Network Information Center website:</p>
</div>
</div>
</body>
</html>