PHP Classes

File: class.html2pcl.php

Recommend this page to a friend!
  Classes of Nurul Ferdous  >  html2pcl  >  class.html2pcl.php  >  Download  
File: class.html2pcl.php
Role: Class source
Content type: text/plain
Description: html2pcl class
Class: html2pcl
Convert HTML to PCL
Author: By
Last change: Listing priority and accessibility changed
Date: 13 years ago
Size: 3,665 bytes


Class file image Download
 * Description of wrapper class Html2pcl *
 * This class is used to produce .PCL and .PS file from HTML file *
 * @Author : Nurul Ferdous *
 * Version : 1.0.0 *
 * Date : 16 Dec 2008 *
 * License : Freeware *
 * Dependancy-1: html2ps package, you may get it from here: *
 * you may install it from terminal by typing "sudo apt-get install html2ps" withpcl quote in kubuntu (in my case) *
 * html2ps uses perl *
 * Dependancy-2: Ghostscript, you may get it from here: *
 * Download it and run "make" command from terminal. you have to download and run exe installer if you use Windows *
 * The ps_output directory is used to store .ps files which are used to generate smaller sized pcl file *
 * keep in your mind that you should have write permission in "pcl_output" directory *
class Html2pcl {

$device = 'laserjet'; //alternatively you may use 'epson' etc as printers
public $paperSize = 'a4'; //alternative you may use 'letter' etc as papersize

function __construct(){
//checking whether the directory named "out" already exists or not
mkdir("./pcl_output", 0755);

//checking whether the directory named "ps_output" already exists or not
mkdir("./ps_output", 0755);

//Clearing file status cache

        return !(
strpos(strtoupper($_SERVER['SERVER_SOFTWARE']), 'WIN32') === false);

//please don't use $htmlFileName without "http://" rather use like this ""
    //please use $pclFileName without the extension like "google"
function makePCL($htmlFileName, $pclFileName){
$file = './pcl_output/'.$pclFileName.'.pcl';
//checking whether the file name given as parameter is already exists or not
exec("perl html2ps $htmlFileName > ./ps_output/".$pclFileName.".ps");
exec("gs -sDEVICE={$this->device} -sPAPERSIZE={$this->paperSize} -sOutputFile=./pcl_output/$pclFileName.pcl -dNOPAUSE -q ./ps_output/$ -c quit");
exec("html2ps $htmlFileName > ./ps_output/".$pclFileName.".ps");
exec("gs -sDEVICE={$this->device} -sPAPERSIZE={$this->paperSize} -sOutputFile=./pcl_output/$pclFileName.pcl -dNOPAUSE -q ./ps_output/$ -c quit");

For more information send a message to info at phpclasses dot org.