| core_file

# Class: Bs_FileConverter Source Location: /core/file/converter/Bs_FileConverter.class.php
### Class Overview
    Bs_Object
       |
       --Bs_FileConverter
Pseudostatic utility class to convert files from one format to another. #### Author(s): andrej arn <at blueshoes dot org> #### Version: 4.3.$Revision: 1.4 $ $Date: 2003/11/05 18:18:09 $ #### Copyright: blueshoes.org | ### Methods Bs_FileConverter capable htmlToPdf htmlToText htmlToWord loadBsHtmlUtil wordStreamToHtmlStream wordStreamToHtmlString wordSummary wordToAbi wordToHtml wordToLatex wordToText wordToWml wordVersion
### Child classes: Bs_FileConverterExcel Pseudostatic utility class to convert files from one format to another. Bs_FileConverterPdf Pseudostatic utility class to convert files from one format to another. | ### Inherited Variables | ### Inherited Methods #### Class: Bs_Object Bs_Object::Bs_Object() Bs_Object::getErrors() Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack. Bs_Object::getLastError() Basic error handling: Get last error string from the global Bs_Error-error stack. Bs_Object::getLastErrors() Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors(). Bs_Object::persist() Persists this object by serializing it and saving it to a file with unique name. Bs_Object::setError() Basic error handling: Push an error string on the global Bs_Error-error stack. Bs_Object::toHtml() Dumps the content of this object to a string using PHP's var_dump(). Bs_Object::toString() Dumps the content of this object to a string using PHP's var_dump(). Bs_Object::unpersist() Fetches an object that was persisted with persist()
### Class Details [line 67] Pseudostatic utility class to convert files from one format to another.
     WISHLIST
     --------
     FROM     TO    | CONVERTER LINUX         | CONVERTER WIN32         | COMMENTS                   |
     ---------------+-------------------------+-------------------------+----------------------------|
     html  -> text  | php (strip tags)        | as linux                |                            |
     html  -> word  |                         |                         |                            |
     html  -> pdf   |                         |                         |                            |
     word  -> html  | wvware                  | as linux (win32 binary) | word me,2000,98,97,95,6.0,2.0  |
     word  -> text  | catdoc                  | as linux (win32 binary) | word me,2000,98,97,95,6.0,2.0 could need 'lynx'.  |
     word  -> pdf   |                         |                         | word me,2000,98,97,95,6.0,2.0 wvware could do this job if the adobe distiller ($$$) is installed.  |
     pdf   -> word  |                         |                         |                            |
     pdf   -> html  |                         |                         |                            |
     pdf   -> text  |                         |                         |                            |
     xls   -> html  | xlhtml                  | xlhtml                  |                            |
     xls   -> text  |                         |                         |                            |
     xls   -> pdf   |                         |                         |                            |
     xls   -> csv   | xlhtml | catdoc         | xlhtml | catdoc         |                            |
     csv   -> xls   | biffwriter              |                         |                            |
     ppt   -> html  |                         |                         |                            |
     ppt   -> text  |                         |                         |                            |
     rtf   -> html
     rtf   -> text
     png   -> gif   |                         |                         |                            |
     png   -> jpg   |                         |                         |                            |
     gif   -> jpg   |                         |                         |                            |
     gif   -> png   |                         |                         |                            |
     gif   -> ascii |                         |                         |                            |
     jpg   -> gif   |                         |                         |                            |
     jpg   -> png   |                         |                         |                            |
     bmp   -> jpg   |                         |                         |                            |
     tiff  -> jpg   |                         |                         |                            |
all methods are called like 'htmlToText', and not the fancy way 'html2text'. this is because of things like 'word62word7' where 'word6ToWord7' looks much better. WORD: the wordTo methods should work with versions 2,6,7,8,9 (known as word 2, 6, 95, 97 and 2000) and are tested using versions 6 and xp. (version 2 is not fully supported.) wordxp supports versioning, that means you can store multiple versions of a document in one file. even then it works fine by using the latest version of your document. the images are not converted. i don't see why. others have similar problems, and i think more work will be done to make the whole install simpler and make everything work. also some ppl have asked for a php module, and that would be nice :). dependencies: Bs_System is loaded right away because it's used often. Bs_HtmlUtil is loaded on demand. #### Tags:
pattern: | singleton: (pseudostatic)
access: | public
version: | 4.3.$Revision: 1.4 $ $Date: 2003/11/05 18:18:09 $
copyright: | blueshoes.org
author: | andrej arn <at blueshoes dot org>
[ Top ] ### Class Methods ### constructor Bs_FileConverter [line 99]
`Bs_FileConverter Bs_FileConverter( )`
[ Top ] ### method capable [line 121]
`bool capable( string $functionName)`
Tells whether we can do a conversion or not. #### Tags:
return: | true if we can, false if not
throws: | NULL on an unknown $functionName
Overridden in child classes as: Bs_FileConverterExcel::capable() Tells whether we can do a conversion or not. Bs_FileConverterPdf::capable() Tells whether we can do a conversion or not. #### Parameters:
string | $functionName | not case sensitive.
[ Top ] ### method htmlToPdf [line 151]
`void htmlToPdf( )`
[ Top ] ### method htmlToText [line 140]
`a &htmlToText( mixed $htmlString, string &$htmlString)`
Convert Html => Text at first it stripps all tags, then converts html entities back to orig values. problems occur if the html is bad, for example if closing tags are missing. #### Tags:
return: | string without html (and php etc) tags.
#### Parameters:
string | &$htmlString |
[ Top ] ### method htmlToWord [line 147]
`void htmlToWord( )`
[ Top ] ### method loadBsHtmlUtil [line 106]
`void loadBsHtmlUtil( )`
[ Top ] ### method wordStreamToHtmlStream [line 265]
`bool wordStreamToHtmlStream( string $source, string $destination)`
converts a word document to html and saves it to $destination. #### Tags:
return: | TRUE
throws: | bs_exception (with custom error text that we can't control cause it comes from the shell.)
#### Parameters:
string | $source | the path and filename to the original word doc.
string | $destination | the path and filename to the newly created file.
[ Top ] ### method wordStreamToHtmlString [line 300]
`string wordStreamToHtmlString( string $source)`
converts a word document to html and returns it as string. #### Tags:
throws: | bs_exception (with custom error text that we can't control cause it comes from the shell.)
#### Parameters:
string | $source | the path and filename to the original word doc.
[ Top ] ### method wordSummary [line 408]
`array wordSummary( string $filePath)`
returns information about the given word document. it looks like word6 documents don't work. i've read that the wordcount is wrong. what you can do is wordToText and then count the words yourself, for example using the unix standard utility wc (wordcount) which tells chars, words and lines. return value; hash with these keys: title, subject, author, keywords, comments, template, lastAuthor, rev (=reference number), appName (application), pageCount, wordCount, charCount, security, codepage. #### Tags:
return: | (hash, see above.)
throws: | FALSE
#### Parameters:
string | $filePath | the path and filename to the word doc.
[ Top ] ### method wordToAbi [line 379]
`mixed &wordToAbi( string $from, [string $to = NULL], bool $clean)`
converts a word document to abiword. converted format may be saved to file or returned. #### Tags:
return: | (bool TRUE if output is saved to file, string otherwise)
see: |
throws: | bs_exception (with custom error text that we can't control cause it comes from the shell.)
#### Parameters:
string | $from | the path and filename to the original word doc.
string | $to | the path and filename to the newly created file. if set to NULL then the converted format will be returned as string.
bool | $clean | default is FALSE, see above
[ Top ] ### method wordToHtml [line 249]
`void wordToHtml( mixed $from, [mixed $to = NULL])`
deprecated, use wordStreamToHtmlStream() or wordStreamToHtmlString() instead. #### Tags:
deprecated: |
[ Top ] ### method wordToLatex [line 354]
`mixed &wordToLatex( string $from, [string $to = NULL], [bool $clean = FALSE])`
converts a word document to latex. converted format may be saved to file or returned. clean parameter: there are 2 xml definition files, wvLaTeX.xml and wvCleanLaTeX.xml. i don't know what the difference is, what it means, but i guess the not-clean one is recommended because of the naming (it's not latex and latexDirty). #### Tags:
return: | (bool TRUE if output is saved to file, string otherwise)
see: |
throws: | bs_exception (with custom error text that we can't control cause it comes from the shell.)
#### Parameters:
string | $from | the path and filename to the original word doc.
string | $to | the path and filename to the newly created file. if set to NULL then the converted format will be returned as string.
bool | $clean | default is FALSE, see above
[ Top ] ### method wordToText [line 215]
`mixed &wordToText( string $from, [string $to = NULL], bool $clean)`
converts a word document to plain text. converted format may be saved to file or returned. #### Tags:
return: | (bool TRUE if output is saved to file, string otherwise)
throws: | bs_exception (with custom error text that we can't control cause it comes from the shell.)
#### Parameters:
string | $from | the path and filename to the original word doc.
string | $to | the path and filename to the newly created file. if set to NULL then the converted format will be returned as string.
bool | $clean | default is FALSE, see above
[ Top ] ### method wordToWml [line 325]
`mixed &wordToWml( string $from, [string $to = NULL], bool $clean)`
converts a word document to wml. converted format may be saved to file or returned. #### Tags:
return: | (bool TRUE if output is saved to file, string otherwise)
see: |
throws: | bs_exception (with custom error text that we can't control cause it comes from the shell.)
#### Parameters:
string | $from | the path and filename to the original word doc.
string | $to | the path and filename to the newly created file. if set to NULL then the converted format will be returned as string.
bool | $clean | default is FALSE, see above
[ Top ] ### method wordVersion [line 520]
`array wordVersion( string $filePath)`
returns information about the word version. return value; hash with these 2 keys: 'version' => (string)['word6', ...] 'encrypted' => (bool)[TRUE|FALSE] note: wordxp identifies itself as word8 (word2000 is older and is word9 ...). #### Tags:
return: | (hash, see above.)
todo: | should we return '6' instead of 'word6', the number only?
throws: | FALSE
#### Parameters:
string | $filePath | the path and filename to the word doc.
[ Top ] Documentation generated on Mon, 29 Dec 2003 21:09:04 +0100 by phpDocumentor 1.2.3