PHPackages                             sun/pdf - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. sun/pdf

ActiveLibrary[Templating &amp; Views](/categories/templating)

sun/pdf
=======

Sun PDF is the pdf generating tools for the serious PHP developers.

v2.0(6y ago)213799MITPHPPHP &gt;=5.5.0

Since Dec 19Pushed 6y ago7 watchersCompare

[ Source](https://github.com/IftekherSunny/PDF)[ Packagist](https://packagist.org/packages/sun/pdf)[ RSS](/packages/sun-pdf/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Sun PDF
-------

[](#sun-pdf)

[![Total Downloads](https://camo.githubusercontent.com/600e663130ce23349ba2e6f07bb83de914ede5cd41be6921fc8677b60478bedd/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f7064662f646f776e6c6f616473)](https://packagist.org/packages/sun/pdf) [![Latest Stable Version](https://camo.githubusercontent.com/8a4d30ac6986b48b899b69d648b4298bf7dac57f6175db951b88714bcebe5c22/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f7064662f762f737461626c65)](https://packagist.org/packages/sun/pdf) [![Latest Unstable Version](https://camo.githubusercontent.com/c788ac854fc301493b8cb2cbbf166b666e9a91c15e7c28fd3f6df610437286b0/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f7064662f762f756e737461626c65)](https://packagist.org/packages/sun/pdf) [![License](https://camo.githubusercontent.com/305795b931279f8ded8c7664288abc472af385f2eb2d144c239d33f76e6cb025/68747470733a2f2f706f7365722e707567782e6f72672f73756e2f7064662f6c6963656e7365)](https://packagist.org/packages/sun/pdf)

Sun PDF is the pdf generating tools for the serious PHP developers.

Installation Process
--------------------

[](#installation-process)

Just copy PDF folder somewhere into your project directory. Then include Sun PDF autoload file.

```
require_once('/path/to/PDF/autoload.php');
```

Sun PDF is also available via Composer/Packagist.

```
composer require sun/pdf

```

Basic Uses
----------

[](#basic-uses)

#### Downloading PDF

[](#downloading-pdf)

```
$pdf = new Sun\PDF;
$pdf->download("Hello world");
```

#### Viewing PDF In The Browser

[](#viewing-pdf-in-the-browser)

```
$pdf = new Sun\PDF;
$pdf->stream("Hello world");
```

#### Getting PDF Output

[](#getting-pdf-output)

```
$pdf = new Sun\PDF;
$pdf->output("Hello world");
```

Changing Configuration
----------------------

[](#changing-configuration)

In the Sun PDF I used PhantomJS. You can change all the configuration of the PhantomJS. To change PhantomJS configuration, you need to pass your own configuration file into Sun PDF constructor.

```
$pdf = new Sun\PDF("/path/to/SunPdf.js");
```

Please, click [This Link](http://phantomjs.org/api/webpage/property/paper-size.html) to know about all the configuration of the PhantomJS.

If you do not wish to pass HTML codes as plain string, you can pass your HTML/PHP file into all the method of the Sun PDF. To use default template engine features you need to setup everything before use. All you have to do for setup is -

```
$pdf = new Sun\PDF(null, "/path/to/views");
```

I used Twig template engine, click [This Link](http://twig.sensiolabs.org/) to know about Twig template engine.

Generating PDF With Template Engine
-----------------------------------

[](#generating-pdf-with-template-engine)

```
$pdf = new Sun\PDF(null, "/path/to/views");

// download pdf
$pdf->download("/path/to/views/test.php", ['name' => 'Iftekher Sunny']);

// viewing pdf in the browser
$pdf->stream("/path/to/views/test.php", ['name' => 'Iftekher Sunny']);
```

Integration In Laravel Framework
--------------------------------

[](#integration-in-laravel-framework)

Add the ServiceProvider to the providers array in config/app.php

```
Sun\Provider\PDFServiceProvider::class,
```

Add the facade to the aliases array in config/app.php

```
'PDF'   =>  Sun\Facade\PDFFacade::class,
```

Integration In Planet Framework
-------------------------------

[](#integration-in-planet-framework)

Add the provider in the config/provider.php file.

```
Sun\Provider\PDFProvider::class,
```

Add the alien in the config/alien.php file.

```
'PDF'   =>  Sun\Alien\PDFAlien::class,
```

License
-------

[](#license)

This package is licensed under the [MIT License](https://github.com/iftekhersunny/PDF/blob/master/LICENSE)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1333 days

Total

2

Last Release

2513d ago

Major Versions

v1.0 → v2.02019-08-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d233b865d7b1e1b86271e3bc70ddd077e1c01e4a83124e020fa39199c4af15a?d=identicon)[IftekherSunny](/maintainers/IftekherSunny)

---

Top Contributors

[![IftekherSunny](https://avatars.githubusercontent.com/u/8013399?v=4)](https://github.com/IftekherSunny "IftekherSunny (6 commits)")

---

Tags

phppdftwigfpdfdompdfsunplanethtml-to-pdf

### Embed Badge

![Health badge](/badges/sun-pdf/health.svg)

```
[![Health](https://phpackages.com/badges/sun-pdf/health.svg)](https://phpackages.com/packages/sun-pdf)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M380](/packages/easycorp-easyadmin-bundle)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M723](/packages/sylius-sylius)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M406](/packages/drupal-core-recommended)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M497](/packages/pimcore-pimcore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
