Download the PHP package khmer-pdf/laravel-kh-pdf without Composer
On this page you can find all versions of the php package khmer-pdf/laravel-kh-pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download khmer-pdf/laravel-kh-pdf
More information about khmer-pdf/laravel-kh-pdf
Files in khmer-pdf/laravel-kh-pdf
Package laravel-kh-pdf
Short Description A simple Laravel package for supporting Khmer font in PDFs using mPdf.
License MIT
Homepage https://github.com/Duch-Nuon/laravel-kh-pdf
Informations about the package laravel-kh-pdf
laravel-kh-pdf
Laravel PDF with Khmer Font Support using mPDF.
Laravel Khmer PDF
Laravel Khmer PDF is a package designed to simplify PDF generation in Laravel with built-in support for Khmer fonts. It integrates seamlessly with mPDF to create professional-looking PDFs.
Installation
Install the package via Composer:
Publish the configuration file:
This will create a config/khPdf.php
file where you can customize font settings and mPDF configurations.
Usage
Basic PDF Generation
Use the PdfKh
facade to generate PDFs:
Methods
The trait provides the following methods:
Method | Description | Example |
---|---|---|
loadHtml($html) |
Sets the HTML content for the PDF. | PdfKh::loadHtml(view('pdf.template')->render()); |
download($filename) |
Prompts the browser to download the generated PDF. | PdfKh::download('file.pdf'); |
stream($filename) |
Displays the PDF directly in the browser. | PdfKh::stream('file.pdf'); |
save($path, $disk) |
Saves the PDF to the specified storage disk. | PdfKh::save('pdfs/report.pdf', 'public'); |
addMPdfConfig($config) |
Adds custom mPDF configuration settings. | PdfKh::addMPdfConfig(['mode' => 'utf-8', 'format' => 'A4-L']); |
watermarkText($text, $opacity, $font, $size, $angle, $color, $config) |
Adds a text watermark to the PDF. | PdfKh::watermarkText('Confidential', 0.2, 'khmeros', 100, 45, '#FF0000', []); |
watermarkImage($path, $size, $position, $opacity, $behindContent, $config) |
Adds an image watermark to the PDF. | PdfKh::watermarkImage('path/to/image.png', 'p', 'p', 1, false, []); |
writeBarcode($code, $horizontal, $vertical, $showIsbn, $size, $border) |
Writes a barcode in the PDF. | PdfKh::writeBarcode('123456789', 10, 10, true, 1, true); |
Examples
template.blade.php
Adding custom mPDF Config
You can configure mPDF settings using the addMPdfConfig
method:
Saving a PDF
Streaming a PDF
Adding a Text Watermark
Adding an Image Watermark
Adding a Barcode
Configuration
The khPdf.php
config file allows you to adjust font paths, default styles, and mPDF options.
Example:
License
This package is open-source software licensed under the MIT license.
Contributions
Contributions are welcome! Feel free to submit pull requests or issues on the GitHub repository.