Download the PHP package omaralalwi/gpdf without Composer
On this page you can find all versions of the php package omaralalwi/gpdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download omaralalwi/gpdf
More information about omaralalwi/gpdf
Files in omaralalwi/gpdf
Package gpdf
Short Description Custom PDF wrapper supporting Arabic language
License MIT
Homepage https://github.com/omaralalwi/gpdf
Informations about the package gpdf
Gpdf : HTML to PDF Converter for PHP & Laravel
Open Source PHP Package for converting HTML to PDF in PHP & Laravel applications, support store to s3, with out-of-the-box support for Arabic content and other languages. Extends dompdf to add new features and solve issues like Arabic language support.
Requirements
- PHP version 8.1 or higher
- DOM extension
- MBString extension
- php-font-lib
- php-svg-lib
Installation
Publish Resources
After installation, publish the config and fonts resources by running the following commands in the root project path:
Note for Publish Issues: If you encounter any issues while publishing, manually copy the vendor/omaralalwi/gpdf/assets/fonts
folder to public/vendor/gpdf
and ensure the fonts are in public/vendor/gpdf/fonts
. Also, copy vendor/omaralalwi/gpdf/config/gpdf.php
to the /config
folder in the root path.
Usage with Native PHP Apps
After installing the package and publishing resources, include autoload.php
and use the Gpdf
class.
Basic Usage
Note: Customize the settings file as needed.
Stream Generated PDF Files
Stream a PDF directly to the browser using generateWithStream
:
Store Files To Local
Save a PDF files to local storage using generateWithStore
:
Note By default it store files to local driver.
generateWithStore params
Parameter | Type | Description |
---|---|---|
html file |
string | The HTML content to be stored. |
store path or bucket name with s3 |
string | The path where the file will be stored, with S3 store this should bucket name. |
file name |
string | The name of the file. |
with stream |
bool | If you need to stream the file to the browser after storing, set this to true . |
sslVerify |
bool | If with stream is set to true , you should set this to true in production to verify SSL. |
Store Files To S3
same to store in local, just replace local path with bucket name, and replace generateWithStore
with generateWithStoreToS3
.
Demo Native PHP App
please see this Demo Native PHP app contain more detailed examples and cases like pass dynamic parameters for html file & pass inline configs , .. and another cases.
Usage with Laravel
Using the Gpdf Facade
Using Dependency Injection
Stream Generated PDF Files
Stream a PDF directly to the browser using generateWithStream
:
Storing Generated PDF Files
Store Files To local
Save a PDF to storage using generateWithStore
:
Note By default it store files to local driver (ensure that: the store path is access able for read and write).
please see generateWithStore params .
Store Files To S3
same to store in local, just replace local path with bucket name, and replace generateWithStore
with generateWithStoreToS3
.
Note Ensure you setup s3 configs in config file.
Generate Advance With Fixed Header
please see this example if you need to add fixed header to all pages
Demo Laravel App
this Demo Laravel app contain more detailed examples and cases.
Supported Fonts
Gpdf supports the following installed fonts (ready to use without any additional configurations):
Support for Arabic
Gpdf supports Arabic content out-of-the-box. Simply pass Arabic text within your HTML content. Make sure to use Arabic fonts, which are included by default.
Supported Arabic Fonts
The following built-in fonts support Arabic:
DejaVu Sans Mono
, Tajawal
, Almarai
, Cairo
, Noto Naskh Arabic
, Markazi Text
.
We Recommended to Use font name from Omaralalwi\Gpdf\Enums\GpdfDefaultSupportedFonts
Enum class , like default font name
in config file .
Examples
Installing New Fonts
To install a new font, follow these steps:
- Ensure the default fonts are published to
public/vendor/gpdf/fonts
. - Prepare at least one font (Normal) for each family
(Normal, Bold, Italic, BoldItalic)
. - Copy the fonts to any path (not the default fonts path).
- The font family name must be enclosed in double quotes and written in lowercase.
- fonts names must be in kebab case with capitalize.
- Run install font script with the following command:
For example, to install the Tajawal
font family:
Features
- Compatibility with any Standard PHP application, Or framework.
- store pdf files to S3 or local storage directly.
- stream pdf files from urls (local or s3).
- Supports 17 fonts by default, including 7 that support Arabic.
- Allows for the installation of custom fonts.
- Provides easy integration with Laravel applications.
- Offers customizable options for PDF generation.
- Includes detailed documentation.
- provide demo applications for quick start-up Demo Native PHP App , Demo Laravel App .
- Unit Tests Includes unit tests.
Thanks
Testing
or
Changelog
See CHANGELOG for recent changes.
Contributing
See CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected]
.
Credits
License
The MIT License (MIT). See LICENSE for more information.
All versions of gpdf with dependencies
aws/aws-sdk-php Version ^3.308
dompdf/dompdf Version ^3.0
khaled.alshamaa/ar-php Version ^6.3