All Projects → YetiForceCompany → YetiForcePDF

YetiForceCompany / YetiForcePDF

Licence: MIT license
The best library in the world to generate PDF from HTML

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to YetiForcePDF

dhtml2pdf
Simple, free and very easy to use PHP API that allows you to see, download or get the binary of the PDF generated from the HTML of an URL.
Stars: ✭ 27 (+80%)
Mutual labels:  html-converter, html2pdf, pdf-generation
MarkdownIt
Efficient Code Editor to live render Markdown and save as Markdown,Html and Pdf with Instant Hosting in The Web.
Stars: ✭ 31 (+106.67%)
Mutual labels:  html-converter, pdf-generation
Openpdf
OpenPDF is a free Java library for creating and editing PDF files with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository. ⛺
Stars: ✭ 2,174 (+14393.33%)
Mutual labels:  pdf-generation
php-chrome-html2pdf
A PHP library for converting HTML to PDF using Google Chrome
Stars: ✭ 53 (+253.33%)
Mutual labels:  html2pdf
Docto
Simple command line utility for converting .doc & .xls files to any supported format such as Text, RTF, CSV or PDF
Stars: ✭ 220 (+1366.67%)
Mutual labels:  pdf-generation
Chrome Headless Render Pdf
Stars: ✭ 164 (+993.33%)
Mutual labels:  pdf-generation
Pdf Bot
🤖 A Node queue API for generating PDFs using headless Chrome. Comes with a CLI, S3 storage and webhooks for notifying subscribers about generated PDFs
Stars: ✭ 2,551 (+16906.67%)
Mutual labels:  pdf-generation
Html2pdf.js
Client-side HTML-to-PDF rendering using pure JS.
Stars: ✭ 2,287 (+15146.67%)
Mutual labels:  pdf-generation
bookjs-eazy
web print / html to pdf so eazy ,HTML自动分页插件。用于生成PDF,前端WEB打印生成PDF或后端wkhtmltopdf、chrome headless生成
Stars: ✭ 99 (+560%)
Mutual labels:  html2pdf
Pdfgen
Simple C PDF Writer/Generation library
Stars: ✭ 200 (+1233.33%)
Mutual labels:  pdf-generation
Markdown Pdf
📄 Markdown to PDF converter
Stars: ✭ 2,365 (+15666.67%)
Mutual labels:  pdf-generation
C4 Builder
This is a documentation builder. You feed it .md and .puml and it exports a site, pdf, or a markdown with navigation.
Stars: ✭ 164 (+993.33%)
Mutual labels:  pdf-generation
Android Pdfmyxml
convert android xml layouts into PDF document, works on all versions of Android.
Stars: ✭ 231 (+1440%)
Mutual labels:  pdf-generation
Wasm Pdf
Generate PDF files with JavaScript and WASM (WebAssembly)
Stars: ✭ 163 (+986.67%)
Mutual labels:  pdf-generation
web-to-pdf
Convert any web technology to PDF (HTML to PDF, html2pdf)
Stars: ✭ 39 (+160%)
Mutual labels:  html2pdf
Reportbro Designer
Javascript plugin to visually design report layouts (for pdf and Excel) which can be created with reportbro-lib (a Python package) on the server.
Stars: ✭ 160 (+966.67%)
Mutual labels:  pdf-generation
Asciidoctor Web Pdf
Convert AsciiDoc documents to PDF using web technologies
Stars: ✭ 219 (+1360%)
Mutual labels:  pdf-generation
Showdown
A bidirectional Markdown to HTML to Markdown converter written in Javascript
Stars: ✭ 12,137 (+80813.33%)
Mutual labels:  html-converter
Publisher
speedata Publisher - a professional database Publishing system
Stars: ✭ 191 (+1173.33%)
Mutual labels:  pdf-generation
Ptex Ng
Asiatic pTeX
Stars: ✭ 239 (+1493.33%)
Mutual labels:  pdf-generation

YetiForcePDF

Latest Stable Version Build Status Scrutinizer Code Quality 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
$loader = require '../vendor/autoload.php';
$document = (new YetiForcePDF\Document())->init();
$document->loadHtml('<div style="text-align:center;">your html goes here</div>');
$pdfFile = $document->render();
file_put_contents('YourPDF.pdf', $pdfFile);

Supported css rules

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

<div data-font data-family="Your Font Name" data-weight="400" data-style="normal" data-file="/absolute/path/to/font/file/YourFontName-Regular.ttf"></div>
<div data-font data-family="Your Font Name" data-weight="400" data-style="italic" data-file="/absolute/path/to/font/file/YourFontName-Italic.ttf"></div>
<div data-font data-family="Your Font Name" data-weight="800" data-style="normal" data-file="/absolute/path/to/font/file/YourFontName-Bold.ttf"></div>
<div data-font data-family="Your Font Name" data-weight="800" data-style="italic" data-file="/absolute/path/to/font/file/YourFontName-BoldItalic.ttf"></div>

You can also add fonts inside php like:

\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

<div data-header>
    <table style="border:1px solid greenyellow;font-size:12px;margin:10px;background-color:yellow;width:100%">
        <tr>
            <td style="width:50%;border:1px solid red;">This is a page header</td>
            <td style="text-align:right;border:1px solid red;">which could be table</td>
        </tr>
    </table>
</div>
<div data-footer>
    <div style="border:1px solid greenyellow;font-size:14px;margin:10px;">
        <div style="text-align:center">Footer</div>
    </div>
</div>
<div data-watermark style="text-align:center;">
    <div style="display:inline-block;font-size:20px;opacity:0.25;">
        <img src="Image.jpg">
    </div>
</div>

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-groups to your html.

<div data-page-group
     data-format="A4"
     data-orientation="P"
     data-margin-left="30"
     data-margin-right="30"
     data-margin-top="40"
     data-margin-bottom="40"
     data-header-top="10"
     data-footer-bottom="10"
></div>

Page break

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

<div style="page-break-after:always;"></div>

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.

<div data-footer>
    <div style="border:1px solid greenyellow;font-size:14px;margin:10px;">
        <div style="text-align:center">Page {p} / {a}</div>
    </div>
</div>

Barcodes

<div data-barcode="EAN13" data-size="1" data-height="16" data-code="9780691147727"></div>

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].