Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/baidou5/laravel-arpdf
PDF Package for Laravel - Supported Arabic character
https://github.com/baidou5/laravel-arpdf
arabic-language laravel-package package pdf-document pdf-generation
Last synced: about 1 month ago
JSON representation
PDF Package for Laravel - Supported Arabic character
- Host: GitHub
- URL: https://github.com/baidou5/laravel-arpdf
- Owner: baidou5
- License: mit
- Created: 2024-09-21T15:56:27.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-20T15:54:48.000Z (2 months ago)
- Last Synced: 2024-10-21T19:57:10.133Z (2 months ago)
- Topics: arabic-language, laravel-package, package, pdf-document, pdf-generation
- Language: PHP
- Homepage:
- Size: 1.19 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![ArPDF Logo](https://raw.githubusercontent.com/baidou5/laravel-arpdf/main/arpdf.jpg)
# Laravel ArPDFA Laravel package for generating PDF files with support for both English and Arabic languages without relying on external libraries.
## Installation
To install the `laravel-arpdf` package, follow these steps:
1. **Add the package to your Laravel project using Composer**:
```bash
composer require baidouabdellah/laravel-arpdf:dev-main
```2. **Register the Service Provider (if using Laravel < 5.5)**:
In your `config/app.php` file, add the following line to the `providers` array:
```php
Baidouabdellah\LaravelArpdf\ArPDFServiceProvider::class,
```3. **Publish the configuration file (optional)**:
You can publish the configuration file to customize the package settings:
```bash
php artisan vendor:publish --provider="Baidouabdellah\LaravelArpdf\ArPDFServiceProvider"
```## Usage
To use the package, you can access the PDF generation functionality in your controller:
Demo Controller
```php
addText(50, 800, 12, 'Hello World');
$pdf->addArabicText(50, 780, 12, 'مرحبا بالعالم');// Save or stream the PDF
$pdf->save('output/sample.pdf');
// Or stream directly to the browser
// $pdf->stream('document.pdf');
}
}```
### Generating a PDF
Here’s an example of how to generate a simple PDF:
```php
$pdf = app('ArPDF');
$pdf->setTitle('Sample PDF');
$pdf->addPage();
$pdf->writeHTML('Hello World
');
$pdf->output('sample.pdf');
```
### Customizing Arabic Font
If you need to customize the Arabic font used in the PDFs, follow these steps:1. **Add the Arabic font files**:
Place your Arabic font files (e.g., TTF or OTF) in the `resources/fonts` directory of your Laravel project.2. **Configure the font in your code**:
In your PDF generation code, you can specify the font like this:```php
$pdf = app('ArPDF');
$pdf->setFont('path/to/your/font.ttf'); // Specify the path to your Arabic font
```
3. **Ensure the font supports Arabic characters**:
Make sure the font you are using supports Arabic characters to display them correctly in the PDF.4. **Example of setting the Arabic font:**
Here’s an example of how to set an Arabic font in your PDF:
```php
$pdf = app('ArPDF');
$pdf->setTitle('Sample PDF');
$pdf->addPage();
$pdf->setFont('resources/fonts/YourArabicFont.ttf');
$pdf->writeHTML('مرحبا بالعالم
'); // Example of Arabic text
$pdf->output('sample.pdf');
```## Support
If you encounter any issues, please open an issue on the [GitHub repository](https://github.com/baidou5/laravel-arpdf/issues).
---
- **Abdellah Baidou**
- Phone: +212 661-176711
- Email: [email protected]----
## License
This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.