Class: HTML_ToPDF

Source Location: /HTML_ToPDF.php

Class Overview [line 40]


A class to convert a local html file to a pdf file on the fly.

Author(s):

Version:

  • 3.3

Copyright:

  • The PHP License

Variables

Constants

Methods


Inherited Variables

Inherited Constants

Inherited Methods



Class Details

A class to convert a local html file to a pdf file on the fly.

Will take a local or remote html file and convert it to a PDF file. Note that you can add encryption or permissions to the PDF file by using the helper PDFEncryptor class that comes with this package. See the README and examples for more information.

Tags:

[ Top ]


Class Variables

$additionalCSS =  ''

[line 108]

Other styles to use when parsing the page

Type: string

Overrides:

[ Top ]

$debug =  false

[line 65]

Whether or not we are in debug mode

Type: bool

Overrides:

[ Top ]

$defaultDomain =  ''

[line 77]

The default domain for relative images

Type: string

Overrides:

[ Top ]

$footers = array('center' => '- $N -')

[line 144]

The footer information

Type: array

Overrides:

[ Top ]

$getUrlPath =  '/usr/bin/curl -i'

[line 95]

The path to your get URL program, including options to get headers

Type: string

Overrides:

[ Top ]

$grayScale =  false

[line 120]

Show the images be in grayscale?

Type: bool

Overrides:

[ Top ]

$headers = array('left' => '$T', 'right' => '$[author]')

[line 138]

The header information

Type: array

Overrides:

[ Top ]

$html2psPath =  '/usr/bin/html2ps'

[line 83]

The path to the html2ps executable

Type: string

Overrides:

[ Top ]

$html2psrc =  '
        option {
          titlepage: 0;         /* do not generate a title page */
          toc: 0;               /* no table of contents */
          colour: %pageInColor%; /* create the page in color */
          underline: %underlineLinks%;         /* underline links */
          grayscale: %grayScale%; /* Make images grayscale? */
          scaledoc: %scaleFactor%; /* Scale the document */
        }
        package {
          geturl: %getUrlPath%; /* path to the geturl */
        }
        showurl: 0;             /* do not show the url next to links */'

[line 150]

Default html2ps configuration that we use (is parsed before being used, though)

Type: string

Overrides:

[ Top ]

$htmlErrors =  false

[line 71]

Whether we output html errors.

Type: bool

Overrides:

[ Top ]

$htmlFile =  ''

[line 47]

The full path to the file we are parsing

Type: string

Overrides:

[ Top ]

$makeAbsoluteImageUrls =  true

[line 161]

Whether HTML_ToPDF should replace all relative image paths in the

input HTML document with the default domain or not. Switch this to false if you want to convert a HTML file which is located locally in the file system and is not reachable via HTTP but all the images used in the HTML file are located correctly according to their relative paths.

Type: bool

Overrides:

[ Top ]

$pageInColor =  true

[line 114]

Show the page in color?

Type: bool

Overrides:

[ Top ]

$pdfFile =  ''

[line 53]

The full path to the output file

Type: string

Overrides:

[ Top ]

$ps2pdfIncludePath =  ''

[line 168]

Include path for ps2pdf (-I option), for example to specify where to search for font files etc.

Type: string

Overrides:

[ Top ]

$ps2pdfPath =  '/usr/bin/ps2pdf'

[line 89]

The path to the ps2pdf executable

Type: string

Overrides:

[ Top ]

$scaleFactor =  1

[line 126]

Scale factore for the page

Type: int

Overrides:

[ Top ]

$tmpDir =  '/tmp'

[line 59]

The temporary directory to save intermediate files

Type: string

Overrides:

[ Top ]

$underlineLinks =  null

[line 132]

Whether to underline links or not

Type: bool

Overrides:

[ Top ]

$useCSS =  true

[line 102]

Whether or not to try and parse the CSS in the html file and use it in

creating the pdf

Type: bool

Overrides:

[ Top ]

$_htmlString =  ''

[line 174]

We use this to store the html file to a string for manipulation

Type: string

Overrides:

[ Top ]


Class Methods

addHtml2PsSettings

void addHtml2PsSettings( string $in_settings)

[line 216]

Adds on more html2ps settings to the end of the default set of settings

Tags:

  • access - public

Parameters:

  • string $in_settings - The additional settings

[ Top ]

convert

string convert( )

[line 475]

Convert the html file into a pdf file

Tags:

  • return - The path to the pdf file
  • access - public

Parameters:

[ Top ]

HTML_ToPdf

void HTML_ToPdf( string $in_htmlFile, string $in_domain, [string $in_pdfFile = null])

[line 190]

Initializes the class

Tags:

  • access - public

Parameters:

  • string $in_htmlFile - The full path to the html file to convert
  • string $in_domain - The default domain name for images that have a relative path
  • string $in_pdfFile - (optional) The full path to the pdf file to output. If not given then we create a temporary name.

[ Top ]

setAdditionalCSS

void setAdditionalCSS( string $in_css)

[line 335]

Set additional CSS to use when parsing the html file

Tags:

  • access - public

Parameters:

  • string $in_css - The additional css

[ Top ]

setDebug

void setDebug( bool $in_debug)

[line 231]

Sets the debug variable

Tags:

  • access - public

Parameters:

  • bool $in_debug - Turn debugging on or off?

[ Top ]

setFooter

void setFooter( string $in_attribute, string $in_value)

[line 273]

Sets a footer

Tags:

  • access - public

Parameters:

  • string $in_attribute - One of the header attributes that html2ps accepts. Most common are left, center, right, font-family, font-size, color.
  • string $in_value - The attribute value. Special values that can be set are $T (document title), $N (page number), $D (current date/time), $U (current url or filename), $[meta-name] (A meta-tag, such as $[author] to get author meta tag)

[ Top ]

setGetUrl

void setGetUrl( string $in_getUrl)

[line 352]

Sets the get url which is used for retrieving images from the html file needs to be the full path to the file with options to retrive the headers as well.

Tags:

  • access - public

Parameters:

  • string $in_getUrl - The get url program

[ Top ]

setGrayScale

void setGrayScale( bool $in_grayScale)

[line 367]

Sets the gray scale option for images

Tags:

  • access - public

Parameters:

  • bool $in_grayScale - Images should be in grayscale?

[ Top ]

setHeader

void setHeader( string $in_attribute, string $in_value)

[line 252]

Sets a header

Tags:

  • access - public

Parameters:

  • string $in_attribute - One of the header attributes that html2ps accepts. Most common are left, center, right, font-family, font-size, color.
  • string $in_value - The attribute value. Special values that can be set are $T (document title), $N (page number), $D (current date/time), $U (current url or filename), $[meta-name] (A meta-tag, such as $[author] to get author meta tag)

[ Top ]

setHtml2Ps

void setHtml2Ps( string $in_html2ps)

[line 413]

Sets the path to the html2ps program

Tags:

  • access - public

Parameters:

  • string $in_html2ps - The html2ps program

[ Top ]

setMakeAbsoluteImageURLs

void setMakeAbsoluteImageURLs( mixed $in_makeAbsoluteImageURLs, bool $in_makeAbsoluteImageUrls)

[line 445]

Sets the makeAbsoluteImageUrls variable

Tags:

  • access - public

Parameters:

  • bool $in_makeAbsoluteImageUrls - Replace relative image URLs in the input HTML file with default domain?

[ Top ]

setPs2Pdf

void setPs2Pdf( string $in_ps2pdf)

[line 428]

Sets the path to the ps2pdf program

Tags:

  • access - public

Parameters:

  • string $in_ps2pdf - The ps2pdf program

[ Top ]

setPs2pdfIncludePath

void setPs2pdfIncludePath( string $in_ps2pdfIncludePath)

[line 461]

Sets the ps2pdfIncludePath() variable

Tags:

  • access - public

Parameters:

  • string $in_ps2pdfIncludePath - The include path for ps2pdf

[ Top ]

setScaleFactor

void setScaleFactor( int $in_scale)

[line 398]

Sets the scale factor for the page. Less than one makes it smaller, greater than one enlarges it.

Tags:

  • access - public

Parameters:

  • int $in_scale - Scale factor

[ Top ]

setTmpDir

void setTmpDir( string $in_path)

[line 289]

Set the temporary directory path

Tags:

  • access - public

Parameters:

  • string $in_path - The full path to the tmp dir

[ Top ]

setUnderlineLinks

void setUnderlineLinks( bool $in_underline)

[line 382]

Sets the option to underline links or not

Tags:

  • access - public

Parameters:

  • bool $in_underline - Links should be underlined?

[ Top ]

setUseColor

void setUseColor( bool $in_useColor)

[line 304]

Set whether to use color or not when creating the page

Tags:

  • access - public

Parameters:

  • bool $in_useColor - Use color?

[ Top ]

setUseCSS

void setUseCSS( bool $in_useCSS)

[line 320]

Set whether to try and use the CSS in the html page when creating the pdf file

Tags:

  • access - public

Parameters:

  • bool $in_useCSS - Use CSS found in html file?

[ Top ]

_dumpDebugInfo

void _dumpDebugInfo( string $in_info)

[line 839]

If debug is on it dumps the specified debug information to screen. Uses

Tags:

  • access - public

Parameters:

  • string $in_info - The debug info

[ Top ]


Class Methods


Documentation generated on Wed, 24 Nov 2004 13:09:40 -0800 by phpDocumentor 1.3.0RC3