This Django web application allows users to upload images and convert them into PDF files. It leverages the powerful Pillow library for image handling and ReportLab for generating PDF files. The application is designed for simplicity, allowing users to upload an image, convert it to PDF, and download the resulting file.
- Image Upload: Supports uploading of images in formats such as PNG, JPEG, etc.
- PDF Conversion: Converts uploaded images to PDF format with the same dimensions as the original image.
- Downloadable PDF: Provides the user with a downloadable PDF file directly from the browser.
- Python 3.x
- Django 4.x
- Pillow
- ReportLab
- Clone the repository:
git clone https://github.com/mmhjmaili/image_to_pdf_with_Django.git
- Navigate to the project directory:
cd image_to_pdf_with_Django
- Create the Django app:
django-admin startapp imagetopdf
- Install the dependencies:
pip install -r requirements.txt
- Apply migrations:
python manage.py migrate
- Run the server:
python manage.py runserver
- Visit
http://127.0.0.1:8000/convert/
in your browser to upload an image and convert it to PDF.
Before running the application, make sure to update the following files:
-
Add the app to
INSTALLED_APPS
inproject/settings.py
:'imagetopdf',
-
Add the app's URLs to
project/urls.py
:path('', include('imagetopdf.urls', namespace='imagetopdf'))
- Navigate to the image upload page.
- Select an image from your local machine.
- Click the "Convert to PDF" button.
- The generated PDF will be available for download immediately.
.
├── imagetopdf
│ ├── migrations
│ ├── forms.py # Django forms for image upload
│ ├── models.py # Image model definition
│ ├── views.py # Logic for converting images to PDF
│ ├── urls.py # URL routing for the app
├── templates
│ └── imagetopdf
│ └── convert_image_to_pdf.html # HTML template for image upload
├── media # Uploaded images and generated PDFs
├── requirements.txt # Project dependencies
├── manage.py
└── README.md
Contributions are welcome! If you have any suggestions or improvements, feel free to open an issue or submit a pull request.
If you need assistance, you can reach out to the developer community on Telegram:
https://t.me/Web_Developer_DevOps
=======================================================================================================================================================================
يتيح لك هذا التطبيق المبني على Django رفع الصور وتحويلها إلى ملفات PDF. يعتمد على مكتبة Pillow للتعامل مع الصور وReportLab لتوليد ملفات PDF. تم تصميم التطبيق ليكون بسيطًا، مما يسمح للمستخدمين برفع صورة، تحويلها إلى PDF، وتنزيل الملف الناتج.
- رفع الصور: يدعم رفع الصور بصيغ مثل PNG وJPEG وغيرها.
- تحويل إلى PDF: يحول الصور المرفوعة إلى صيغة PDF بنفس أبعاد الصورة الأصلية.
- تنزيل ملف PDF: يوفر للمستخدم ملف PDF جاهزًا للتنزيل مباشرةً من المتصفح.
- Python 3.x
- Django 4.x
- Pillow
- ReportLab
- استنساخ المستودع:
git clone https://github.com/mmhjmaili/image_to_pdf_with_Django.git
- الانتقال إلى مجلد المشروع:
cd image_to_pdf_with_Django
- إنشاء التطبيق:
django-admin startapp imagetopdf
- تثبيت المتطلبات:
pip install -r requirements.txt
- تطبيق الترقيات:
python manage.py migrate
- تشغيل الخادم:
python manage.py runserver
- زيارة الرابط التالي في المتصفح لتحويل الصور إلى PDF:
http://127.0.0.1:8000/convert/
قبل تشغيل التطبيق، تأكد من تحديث الملفات التالية:
-
إضافة التطبيق إلى
INSTALLED_APPS
فيproject/settings.py
:'imagetopdf',
-
إضافة روابط التطبيق إلى
project/urls.py
:path('', include('imagetopdf.urls', namespace='imagetopdf'))
- انتقل إلى صفحة رفع الصور.
- اختر صورة من جهازك.
- اضغط على زر "تحويل إلى PDF".
- سيكون ملف PDF الناتج جاهزًا للتنزيل فورًا.
.
├── imagetopdf
│ ├── migrations
│ ├── forms.py # استمارات Django لرفع الصور
│ ├── models.py # تعريف نموذج الصور
│ ├── views.py # المنطق لتحويل الصور إلى PDF
│ ├── urls.py # توجيه روابط التطبيق
├── templates
│ └── imagetopdf
│ └── convert_image_to_pdf.html # قالب HTML لرفع الصور
├── media # الصور المرفوعة وملفات PDF الناتجة
├── requirements.txt # الاعتماديات الخاصة بالمشروع
├── manage.py
└── README.md
المساهمات مرحب بها! إذا كانت لديك اقتراحات أو تحسينات، لا تتردد في فتح قضية أو إرسال طلب سحب.
إذا كنت بحاجة إلى مساعدة، يمكنك التواصل مع مجتمع المطورين عبر تيليجرام: