Git Product home page Git Product logo

h2p's Introduction

H2P Build Status

Convert your HTML files to PDF with ease. Thanks to PhantomJS, you can write CSS3, HTML5 and Javascript and it will convert and print your files just like you see them in your browser.

WIP-2.0

This branch is the WIP for the new version. Anything here can be changed until the release. There are breaking changes since 1.0.

How to use

It's very simple, but first you must download the PhantomJS binary file according to your system (Windows, Mac, Linux-X86 or Linux-X86_64) and put it in the right bin folder.

You can download it here: http://phantomjs.org/download.html

use H2P\Converter\PhantomJS;
use H2P\TempFile;

$converter = new PhantomJS();
$output = new TempFile();

// Convert destination accepts TempFile or string with the path to save the file
$converter->convert('http://www.google.com/', $output);

// Save it somewhere
$output->save('/another/path/to/file.pdf');
// or send
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/pdf');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($output->getFileName()));
readfile($output->getFileName());

You can find more examples in the samples folder.

Composer

Just put { "kriansa/h2p": "dev-wip-2.0" } into your require property.

License

  • MIT License

h2p's People

Contributors

kriansa avatar dhavalbudhelia avatar tristankenney avatar danielpigott avatar vjnrv avatar romeosanjose avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar luke avatar Suchan Badyakar avatar Ruffy Collado avatar  avatar  avatar Cale O'Bryan avatar  avatar

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.