Giter Site home page Giter Site logo

pdf's Introduction

Sun PDF

Total Downloads Latest Stable Version Latest Unstable Version License

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

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

Downloading PDF

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

Viewing PDF In The Browser

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

Getting PDF Output

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

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 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 to know about Twig 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

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

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

This package is licensed under the MIT License

pdf's People

Contributors

iftekhersunny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdf's Issues

img tag seems not working

Hi, IftekherSunny.
I found your script is helpfull, but i couldn't use img tag on my template.
here is the script:

<img alt="logo" src="img/logo.png" width="300" height="80" />

The rendered pdf just show a box with grey border and the alt text, which is look similar to not found image but when I run the code above directly, it shown the logo.

Could you help me with this?

save pdf to folder

Hi maybe Im missing something obvious! but how do I save the pdf to a folder on the server? - my process will be a cron job so it needs to be automated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.