Download the PHP package biztecheg/easy-pdf-word without Composer

On this page you can find all versions of the php package biztecheg/easy-pdf-word. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package easy-pdf-word

Easy PDF & Word

Tests Latest version PHP

Generate PDF and Word (.docx) documents in plain PHP, in any language, with first-class Arabic support and ready-made templates. No framework needed: it works in WordPress, Symfony, CodeIgniter or a plain script.

Using Laravel? Install biztecheg/laravel-easy-pdf-word instead. It is built on this package and adds the Doc facade, config, Blade views, storage disks, downloads, mail, queues and a preview page.

Documentation: easypdf.biztech-eg.com (English and Arabic).

العربية

Requirements

Installation

Usage

create() takes the same settings as the Laravel package's config/easy-pdf-word.php; leave out what you do not change. EasyPdfWord::defaults() returns them all.

Local images (a logo, a signature) are read only from the folders you list, and none are listed by default. Add yours, or the image is left out with a warning in the PHP error log:

A ready-made template

The data is checked against the template's rules first. A mistake throws BiztechEG\EasyPdfWord\Exceptions\ValidationFailed, whose errors() lists the messages by field.

A document built in code

The same blocks make a Word file with ->word().

Text can be a list of runs, each with its own style: bold, italic, size, color and background (a hex value, rgb() or a CSS colour name such as navy), underline, strike, link (http, https or mailto), font and ltr. They look the same in PDF and Word:

Lists are numbered or bulleted from the start side, with sub-lists, in PDF and Word:

An item is a string, a run, a list of runs, or [item, [sub-items]]. start sets the first number, and size, color, bold, italic and space_after style the list.

A font must be registered (see Your own fonts): the PDF has no file for other names, so they are left out and reported through warn. In Word, a registered font becomes its word name, or the Word font.

A table row can have its own style, be a total row (bold, with a line above it) or stay on one page with the next row, so a section heading never ends a page:

A cell's own style wins over its row's. Several rows can be totals; footer => true still makes the last row bold.

A cell's overlay draws a stamp over it, behind its text, such as a company stamp over the signature:

width and height are in mm, and the image keeps its proportions unless stretch => true. offset is [start, down] in mm from the cell's start-top corner: a positive start moves toward the right in Arabic. The image follows the document's image rules. In PDF the stamp is the cell's background, so what lies past the cell's edges is cut off; in Word it floats behind the text.

Tables take borders ('rows', the default, 'grid' or 'none'), border_width in points, padding in mm and valign (top, middle, bottom); a cell can set its own padding and valign. keep_together => true keeps a small table, such as the totals, on one page. A cell with rowspan covers the cells below it, written the HTML way:

In tests, ->blocks() gives a document's body blocks and ->text() its text, headers and footers first, without rendering: table cells are joined with tabs, rows with new lines, and rich text is reduced to its text. A template's layout.php or word.php runs with the data; views and HTML have no blocks.

Headers and footers

header() and footer() take HTML, or blocks built in code. Blocks work in PDF and Word, so a letterhead with a logo in a table looks the same in both, and the first page can have its own:

A header or footer takes paragraph, table, image, line and spacer blocks, and its text may use {page} and {pages}. With mPDF, a header taller than the top margin pushes the body down, as in Word. Chromium and Gotenberg give every page the same header and footer. Templates can hold the same as header.layout.php, footer.layout.php, first-header.layout.php and first-footer.layout.php.

Watermarks

->watermark('مسودة') writes text across every page of a PDF. For PDF and Word alike, use an image: Word cannot draw a text watermark, so "مسودة / DRAFT" is an image you prepare once.

The image sits in the middle of every page, width mm wide (140 by default), and follows the document's image rules. In Word it lives in the page header, faded with GD, on the first page too when that has its own header.

Your own HTML or views

Views are plain PHP files. They get your data as variables and $doc, the document helpers: $doc->e() escapes a value, $doc->money(), $doc->date(), $doc->inWords(), $doc->hijri() and $doc->ltr() format it for the document's language.

HTML from a rich-text editor

richText() adds HTML that users write in an editor to a document built in code, such as the terms of a price offer. The HTML is cleaned first, so it is safe to pass as it is, unlike html():

Headings take the builder's sizes, tables get borders around every cell, and the block follows the document's direction and numerals. Its images must be data URIs or allowed URLs (images.remote); paths to files on the server are refused, even in images.paths. Word files keep the formatting too: headings, lists numbered from the right in Arabic, quotes, tables with merged cells, links and images. If Word cannot take a block, its text is written instead and warn is told.

To clean the HTML yourself, before storing it for example, Support\HtmlSanitizer cleans HTML that users write in an editor such as TipTap or CKEditor. It keeps headings, paragraphs, bold, italic, underline, strike-through, highlight, colours, alignment, lists, quotes, links, tables and images, and removes scripts, event attributes, other styles and links that are not http, https or mailto:

By default images are kept only when they are http(s) URLs or PNG, JPEG, GIF or WebP data URIs; pass a closure as the first argument to check them your way. The input is limited to 256 KB, 20 levels of nesting and tables of 200 rows and 20 columns; what goes beyond is cut, and the optional warn closure is told.

Your own templates

A template is a folder with template.php (fields, defaults, sample data), a PDF page pdf.html.php or a code layout layout.php, optional word.php or word.docx, header.html.php and footer.html.php or their *.layout.php versions built in code, and lang/*.json labels (or lang/*.php). Point templates.paths at your folders:

The bundled templates in custom templates guide explains every file.

Languages

The bundled templates come in Arabic, English and Turkish:

What the library knows about a language lives in JSON files, so other versions of the library can read the same files:

To add a language, add both: a language file in a folder of yours, and a lang/{language}.json in your copy of each template you use.

Amounts in words in languages other than Arabic need ext-intl. The Cairo and Noto Naskh fonts have the Turkish letters; Tajawal does not.

Arabic helpers

The global functions tafqeet(), hijri_date() and arabic_numerals() do the same.

Your own fonts

Word files do not carry fonts. Add 'word' => 'My Font' to a font when your readers have it installed: a run with 'font' => 'my-font' then uses it in Word, and otherwise the Word font (word.font, Arial by default).

Some Arabic fonts need their tables fixed before mPDF can shape them:

The bundled fonts are already fixed this way.

Security

The package treats the data you pass to a template as untrusted: text is escaped in templates, documents built in code and Word files; local images are read only from the folders in images.paths; image URLs are ignored unless you allow their hosts; colours, locales and font names must be real values. HTML you pass to html() and the templates and views you write are code, and are used as written; clean HTML from users with HtmlSanitizer first. See SECURITY.md to report a vulnerability.

On shared hosting the system's temp folder is shared with other accounts, and documents pass through it while they are made. Set temp_dir to a folder of your own, and Word files, .docx templates, ZIP files and Chromium write their temp files there:

The folder is created when missing. mPDF keeps its own setting, pdf.drivers.mpdf.temp_dir, which by default is already a folder only your system user can open.

License

MIT. The bundled fonts are under the SIL Open Font License (see resources/fonts). mPDF, an optional engine, is GPL-2.0.

بالعربي

مكتبة PHP لإنشاء ملفات PDF وWord بأي لغة، مع دعم كامل للعربية وقوالب جاهزة. لا تحتاج إلى إطار عمل، فتعمل في WordPress وSymfony وCodeIgniter أو في سكريبت PHP عادي. ولمشاريع Laravel استخدم biztecheg/laravel-easy-pdf-word المبنية على هذه المكتبة.

التوثيق الكامل بالعربية: easypdf.biztech-eg.com/ar.


All versions of easy-pdf-word with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-mbstring Version *
ext-gd Version *
chillerlan/php-qrcode Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package biztecheg/easy-pdf-word contains the following files

Loading the files please wait ...