creating reports in arabic with django

iam trying to create a report using django but the arabic word coes out redacted for some reason this is the and example of the pdf

this is my view function
this function and templates works just fine with downloading the pdf but when it comes out to rendering arabic it does’t work
i have downloaded this arabic font NotoKufiArabic-VariableFont_wght.ttf but it won’t work for some reason

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>from django.http import HttpResponse
from django.template.loader import get_template
from xhtml2pdf import pisa
from io import BytesIO
from django.shortcuts import get_object_or_404
from ..models import Supplier, TransactionModel
from django.db.models import Sum
def generate_pdf_report(request, supplier_name):
supplier = get_object_or_404(Supplier, supplier_name=supplier_name)
transactions = TransactionModel.objects.filter(supplier_name=supplier).order_by('payment_date')
total_paid = transactions.aggregate(Sum('payment_amount'))['payment_amount__sum'] or 0
remaining_amount = supplier.total_amount - total_paid
context = {
'supplier': supplier,
'transactions': transactions,
'total_paid': total_paid,
'remaining_amount': remaining_amount,
}
template = get_template('supplier_report.html')
html = template.render(context)
result = BytesIO()
pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result, encoding='UTF-8')
if not pdf.err:
response = HttpResponse(result.getvalue(), content_type='application/pdf')
response['Content-Disposition'] = f'attachment; filename="{supplier_name}_report.pdf"'
return response
return HttpResponse('Error generating PDF', status=400)
</code>
<code>from django.http import HttpResponse from django.template.loader import get_template from xhtml2pdf import pisa from io import BytesIO from django.shortcuts import get_object_or_404 from ..models import Supplier, TransactionModel from django.db.models import Sum def generate_pdf_report(request, supplier_name): supplier = get_object_or_404(Supplier, supplier_name=supplier_name) transactions = TransactionModel.objects.filter(supplier_name=supplier).order_by('payment_date') total_paid = transactions.aggregate(Sum('payment_amount'))['payment_amount__sum'] or 0 remaining_amount = supplier.total_amount - total_paid context = { 'supplier': supplier, 'transactions': transactions, 'total_paid': total_paid, 'remaining_amount': remaining_amount, } template = get_template('supplier_report.html') html = template.render(context) result = BytesIO() pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result, encoding='UTF-8') if not pdf.err: response = HttpResponse(result.getvalue(), content_type='application/pdf') response['Content-Disposition'] = f'attachment; filename="{supplier_name}_report.pdf"' return response return HttpResponse('Error generating PDF', status=400) </code>
from django.http import HttpResponse
from django.template.loader import get_template
from xhtml2pdf import pisa
from io import BytesIO
from django.shortcuts import get_object_or_404
from ..models import Supplier, TransactionModel
from django.db.models import Sum

def generate_pdf_report(request, supplier_name):
    supplier = get_object_or_404(Supplier, supplier_name=supplier_name)
    transactions = TransactionModel.objects.filter(supplier_name=supplier).order_by('payment_date')
    
    total_paid = transactions.aggregate(Sum('payment_amount'))['payment_amount__sum'] or 0
    remaining_amount = supplier.total_amount - total_paid

    context = {
        'supplier': supplier,
        'transactions': transactions,
        'total_paid': total_paid,
        'remaining_amount': remaining_amount,
    }

    template = get_template('supplier_report.html')
    html = template.render(context)

    result = BytesIO()
    pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result, encoding='UTF-8')
    
    

    if not pdf.err:
        response = HttpResponse(result.getvalue(), content_type='application/pdf')
        response['Content-Disposition'] = f'attachment; filename="{supplier_name}_report.pdf"'
        return response
    return HttpResponse('Error generating PDF', status=400)

and this is my template

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<title>تقرير المورد - {{ supplier.supplier_name }}</title>
<style>
@font-face {
font-family: 'Arabic Font';
src: url('../../NotoKufiArabic-VariableFont_wght.ttf') format('truetype');
}
body {
font-family: 'ArialArabic', Arial, sans-serif;
direction: rtl;
text-align: right;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: right;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h1>تقرير المورد - {{ supplier.supplier_name }}</h1>
<p>نوع المورد: {{ supplier.get_supplier_type_display }}</p>
<p>طريقة الدفع: {{ supplier.get_payment_method_display }}</p>
<p>المبلغ الكلي: {{ supplier.total_amount }}</p>
<p>المبلغ المدفوع: {{ total_paid }}</p>
<p>المبلغ المتبقي: {{ remaining_amount }}</p>
<p>تاريخ الدفعة القادمة: {{ supplier.next_payment_date }}</p>
<p>اسم المصدر: {{ supplier.issuer_name }}</p>
<p>البريد الإلكتروني: {{ supplier.email }}</p>
<h2>جدول المعاملات</h2>
<table>
<thead>
<tr>
<th>رقم الدفعة</th>
<th>تاريخ الدفع</th>
<th>قيمة الدفعة</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr>
<td>{{ transaction.payment_num }}</td>
<td>{{ transaction.payment_date }}</td>
<td>{{ transaction.payment_amount }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>```
</code>
<code><html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <title>تقرير المورد - {{ supplier.supplier_name }}</title> <style> @font-face { font-family: 'Arabic Font'; src: url('../../NotoKufiArabic-VariableFont_wght.ttf') format('truetype'); } body { font-family: 'ArialArabic', Arial, sans-serif; direction: rtl; text-align: right; } table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid #ddd; padding: 8px; text-align: right; } th { background-color: #f2f2f2; } </style> </head> <body> <h1>تقرير المورد - {{ supplier.supplier_name }}</h1> <p>نوع المورد: {{ supplier.get_supplier_type_display }}</p> <p>طريقة الدفع: {{ supplier.get_payment_method_display }}</p> <p>المبلغ الكلي: {{ supplier.total_amount }}</p> <p>المبلغ المدفوع: {{ total_paid }}</p> <p>المبلغ المتبقي: {{ remaining_amount }}</p> <p>تاريخ الدفعة القادمة: {{ supplier.next_payment_date }}</p> <p>اسم المصدر: {{ supplier.issuer_name }}</p> <p>البريد الإلكتروني: {{ supplier.email }}</p> <h2>جدول المعاملات</h2> <table> <thead> <tr> <th>رقم الدفعة</th> <th>تاريخ الدفع</th> <th>قيمة الدفعة</th> </tr> </thead> <tbody> {% for transaction in transactions %} <tr> <td>{{ transaction.payment_num }}</td> <td>{{ transaction.payment_date }}</td> <td>{{ transaction.payment_amount }}</td> </tr> {% endfor %} </tbody> </table> </body> </html>``` </code>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <title>تقرير المورد - {{ supplier.supplier_name }}</title>
    <style>
        @font-face {
            font-family: 'Arabic Font';
            src: url('../../NotoKufiArabic-VariableFont_wght.ttf') format('truetype');
        }
        body {
            font-family: 'ArialArabic', Arial, sans-serif;
            direction: rtl;
            text-align: right;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: right;
        }
        th {
            background-color: #f2f2f2;
        }
    </style>
</head>
<body>
    <h1>تقرير المورد - {{ supplier.supplier_name }}</h1>
    <p>نوع المورد: {{ supplier.get_supplier_type_display }}</p>
    <p>طريقة الدفع: {{ supplier.get_payment_method_display }}</p>
    <p>المبلغ الكلي: {{ supplier.total_amount }}</p>
    <p>المبلغ المدفوع: {{ total_paid }}</p>
    <p>المبلغ المتبقي: {{ remaining_amount }}</p>
    <p>تاريخ الدفعة القادمة: {{ supplier.next_payment_date }}</p>
    <p>اسم المصدر: {{ supplier.issuer_name }}</p>
    <p>البريد الإلكتروني: {{ supplier.email }}</p>
    
    <h2>جدول المعاملات</h2>
    <table>
        <thead>
            <tr>
                <th>رقم الدفعة</th>
                <th>تاريخ الدفع</th>
                <th>قيمة الدفعة</th>
            </tr>
        </thead>
        <tbody>
            {% for transaction in transactions %}
            <tr>
                <td>{{ transaction.payment_num }}</td>
                <td>{{ transaction.payment_date }}</td>
                <td>{{ transaction.payment_amount }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
</html>```

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật