I'm using fillpdf library to fill in a PDF form. When I use it externally 
it works fine and all.
When I save the file generated by fillpdf to my model the Arabic text 
becomes reversed.

[image: Screenshot 2024-05-14 120336.png]

This is my code:

import requests
        from fillpdf import fillpdfs
        from django.core.files import File, base
        from io import BytesIO
        from django.forms.models import model_to_dict

        ctx = {
            'full_name': 'منصور أحمد',
            'current_nationality': 'الإمارات العربية المتحدة'
        }

        response = requests.get(
"http://localhost:8000/static/document/form.pdf";)
        if not response.ok:
            log.error("couldn't get form")

        in_stream = BytesIO(response.content)
        out_stream = BytesIO()

        fillpdfs.write_fillable_pdf(
            in_stream,
            out_stream,
            ctx,
            flatten=True
        )

        with open("output.pdf", "wb") as f:
            f.write(out_stream.getbuffer())

        application.arabic_document.save("Some fillpdf file.pdf", base.
ContentFile(out_stream.getbuffer()))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7769405-358e-4f83-bd1f-90ef2fc61b47n%40googlegroups.com.

Reply via email to