Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yetiforcecompany/yetiforcepdf

The best library in the world to generate PDF from HTML
https://github.com/yetiforcecompany/yetiforcepdf

free html html-converter html2pdf opensource pdf pdf-generation php

Last synced: 3 days ago
JSON representation

The best library in the world to generate PDF from HTML

Awesome Lists containing this project

README

        

# YetiForcePDF
[![Latest Stable Version](https://poser.pugx.org/yetiforce/yetiforcepdf/v/stable)](https://packagist.org/packages/yetiforce/yetiforcepdf)
[![Build Status](https://travis-ci.org/YetiForceCompany/YetiForcePDF.svg?branch=developer)](https://travis-ci.org/YetiForceCompany/YetiForcePDF)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/YetiForceCompany/YetiForcePDF/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/YetiForceCompany/YetiForcePDF/?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/af478ddd07cf7278841a/maintainability)](https://codeclimate.com/github/YetiForceCompany/YetiForcePDF/maintainability)

## PDF generation library for PHP
The best library in the world to generate PDF from HTML

## Issues & bugs
Report errors related to PDF in https://github.com/YetiForceCompany/YetiForceCRM/issues

## Basic usage (for more take a look at examples folder)

```php
init();
$document->loadHtml('

your html goes here
');
$pdfFile = $document->render();
file_put_contents('YourPDF.pdf', $pdfFile);
```

### Supported css rules

- [x] font-family
- [x] font-size
- [x] font-weight
- [x] font-style
- [x] margin [px, em, cm, mm, pt, in]
- [x] margin-left [px, em, cm, mm, pt, in]
- [x] margin-top [px, em, cm, mm, pt, in]
- [x] margin-right [px, em, cm, mm, pt, in]
- [x] margin-bottom [px, em, cm, mm, pt, in]
- [x] padding [px, em, cm, mm, pt, in]
- [x] padding-left [px, em, cm, mm, pt, in]
- [x] padding-top [px, em, cm, mm, pt, in]
- [x] padding-right [px, em, cm, mm, pt, in]
- [x] padding-bottom [px, em, cm, mm, pt, in]
- [x] border [px, em, cm, mm, pt, in]
- [x] border-left
- [x] border-top
- [x] border-right
- [x] border-bottom
- [x] border-left-width [px, em, cm, mm, pt, in]
- [x] border-top-width [px, em, cm, mm, pt, in]
- [x] border-right-width [px, em, cm, mm, pt, in]
- [x] border-bottom-width [px, em, cm, mm, pt, in]
- [x] border-color [hex, rgb]
- [x] border-left-color [hex, rgb]
- [x] border-top-color [hex, rgb]
- [x] border-right-color [hex, rgb]
- [x] border-bottom-color [hex, rgb]
- [ ] border-style
- [ ] border-left-style
- [ ] border-top-style
- [ ] border-right-style
- [ ] border-bottom-style
- [ ] box-sizing
- [x] display [block, inline, inline-block, none]
- [x] width [%, px, em, cm, mm, pt, in]
- [x] height [%, px, em, cm, mm, pt, in]
- [ ] overflow
- [x] vertical-align [baseline, top, bottom, middle]
- [x] line-height [px, em, cm, mm, pt, in]
- [x] background-color [hex, rgb]
- [x] color [hex, rgb, rgba, named]
- [x] word-wrap [normal]
- [ ] max-width
- [ ] min-width
- [x] white-space [normal]
- [ ] word-wrap
- [ ] float
- [ ] clear
- [x] table displays
- [x] background-image
- [x] rgb / rgba color

### Available fonts by default

- DejaVu Sans

### Custom fonts

Upload your ttf font files to server and add following code at the beginning of your html.

Each font weight and style could be defined if your font supports it.

```php





```

You can also add fonts inside php like:

```php
\YetiForcePDF\Document::addFonts([
[
'family' => 'Pacifico',
'weight' => '400',
'style' => 'normal',
'file' => '/absolute/path/to/Pacifico/Pacifico-Regular.ttf'
],
[
'family' => 'Lobster Two',
'weight' => '400',
'style' => 'normal',
'file' => '/absolute/path/to/Lobster_Two/LobsterTwo-Regular.ttf'
],
[
'family' => 'Lobster Two',
'weight' => 'bold',
'style' => 'normal',
'file' => '/absolute/path/to/Lobster_Two/LobsterTwo-Bold.ttf'
],
]);
```

### Headers, footers and watermarks

You can define header, footer and watermark to be displayed inside pdf file

```php




This is a page header
which could be table





Footer








```

### Page format, orientation and margins

Page format, orientation and margins could be defined from YetiForcePDF instance or inside html code.

If you have multiple page formats and orientations inside one pdf document you can insert multiple `data-page-group`s to your html.

```php


```

### Page break

When you want to add new page use `data-page-group` or set style on div element `page-break-after:always`.

```php


```

### Page numbering

When you want to place page number (in header or footer for example) you can do it by placing `{p}` or `{a}` text inside your html - it will be replaced by `{p}` page number or `{a}` all pages count.

```php



Page {p} / {a}



```

### Barcodes

```php


```

### TODO (later but important)
- [ ] floats
- [ ] display: list-item
- [ ] basic transformations (rotateXY, scaleXY, translateXY)
- [ ] position (absolute, relative)

## License

Distributed under the MIT license. See LICENSE for details.

## 👥 Contributors

This project exists thanks to all the people who contribute.