本文整理汇总了PHP中parse_config_file函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_config_file函数的具体用法?PHP parse_config_file怎么用?PHP parse_config_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_config_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
// Include the class file and create Html2ps instance
App::import('vendor', 'Html2PsConfig', array('file' => 'html2ps' . DS . 'config.inc.php'));
App::import('vendor', 'Html2Ps', array('file' => 'html2ps' . DS . 'pipeline.factory.class.php'));
parse_config_file(APP . 'vendors' . DS . 'html2ps' . DS . 'html2ps.config');
global $g_config;
$g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false);
$this->media = Media::predefined('A4');
$this->media->set_landscape(false);
$this->media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0));
$this->media->set_pixels(1024);
global $g_px_scale;
$g_px_scale = mm2pt($this->media->width() - $this->media->margins['left'] - $this->media->margins['right']) / $this->media->pixels;
global $g_pt_scale;
$g_pt_scale = $g_pt_scale * 1.43;
$this->p = PipelineFactory::create_default_pipeline("", "");
switch ($this->output) {
case 'download':
$this->p->destination = new DestinationDownload($this->filename);
break;
case 'file':
$this->p->destination = new DestinationFile($this->filename);
break;
default:
$this->p->destination = new DestinationBrowser($this->filename);
break;
}
}
示例2: runPipeline
function runPipeline($html, &$media = null, &$pipeline = null, &$context = null, &$postponed = null)
{
parse_config_file('../html2ps.config');
if (is_null($media)) {
$media = Media::predefined("A4");
}
$pipeline = $this->preparePipeline($media);
$tree = $this->layoutPipeline($html, $pipeline, $media, $context, $postponed);
return $tree;
}
示例3: runPipeline
function runPipeline($html)
{
$pipeline = PipelineFactory::create_default_pipeline("", "");
$pipeline->configure(array('scalepoints' => false));
$pipeline->fetchers = array(new MyFetcherMemory($html, ""));
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
$pipeline->destination = new DestinationFile("test.pdf");
parse_config_file('../html2ps.config');
$media = Media::predefined("A5");
$pipeline->_prepare($media);
return $pipeline->_layout_item("", $media, 0, $context, $positioned_filter);
}
示例4: get_extra_conf
function get_extra_conf($safe_category)
{
$template_dir = get_template_dir();
if (!$safe_category) {
return false;
}
$custom_path = $template_dir . strtolower(preg_replace("/[^\\w]/i", "", $safe_category)) . "/" . strtolower(preg_replace("/[^\\w]/i", "", $safe_category)) . ".conf";
if (file_exists($custom_path)) {
$data = file_get_contents($custom_path);
parse_config_file($data);
}
}
示例5: testCSSParseMarginBoxesTopLeftSize
function testCSSParseMarginBoxesTopLeftSize()
{
parse_config_file('../html2ps.config');
$media =& Media::predefined('A4');
$media->set_margins(array('left' => 10, 'top' => 10, 'right' => 10, 'bottom' => 10));
$pipeline =& PipelineFactory::create_default_pipeline('utf-8', 'test.pdf');
$pipeline->_prepare($media);
$pipeline->_cssState = array(new CSSState(CSS::get()));
parse_css_atpage_rules('@page { @top-left { content: "TEXT"; } }', $pipeline);
$boxes = $pipeline->reflow_margin_boxes(1, $media);
$box =& $boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT];
$this->assertNotEqual($box->get_width(), 0);
$expected_width = $pipeline->output_driver->stringwidth('TEXT', 'Times-Roman', 'iso-8859-1', 12);
$this->assertTrue($box->get_width() >= $expected_width);
$this->assertEqual($box->get_height(), mm2pt(10));
}
示例6: testCheckedRadioPngRender
function testCheckedRadioPngRender()
{
parse_config_file('../html2ps.config');
$media = Media::predefined("A4");
$pipeline = $this->preparePipeline($media);
$pipeline->output_driver = new OutputDriverPng();
$pipeline->fetchers = array(new MyFetcherMemory('
<html>
<head></head>
<body>
<input type="radio" name="name" checked="checked"/>
</body>
</html>
', ''));
$tree = $pipeline->_layout_item('', $media, 0, $context, $postponed_filter);
$this->assertNotNull($tree);
$pipeline->_show_item($tree, 0, $context, $media, $postponed_filter);
}
示例7: cw_pdf_generate
function cw_pdf_generate($file, $template, $save_to_file = false, $landscape = false, $pages_limit = 0, $page_margins = array('10', '10', '10', '10'), $show_pages = true)
{
global $smarty, $var_dirs, $current_location;
set_time_limit(2700);
ini_set('memory_limit', '512M');
$smarty->assign('is_pdf', true);
# kornev, only for A4 && 1024 p/wide
$wcr = $hcr = 1024 / 210;
$smarty->assign('wcr', $wcr);
$smarty->assign('hcr', $hcr);
if ($save_to_file && $file) {
$html = $file;
} else {
$html = cw_display($template, $smarty, false);
}
parse_config_file(HTML2PS_DIR . 'html2ps.config');
$pipeline = PipelineFactory::create_default_pipeline('', '');
$pipeline->fetchers[] = new MyFetcherMemory($html, $current_location);
if ($save_to_file) {
$pipeline->destination = new MyDestinationFile($save_to_file);
} else {
$pipeline->destination = new DestinationDownload($file);
}
if ($show_pages) {
$pipeline->pre_tree_filters[] = new PreTreeFilterHeaderFooter('', '<div>' . cw_get_langvar_by_name('lbl_page', null, false, true) . ' ##PAGE## / ##PAGES## </div>');
}
$pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields();
$media =& Media::predefined('A4');
$media->set_landscape($landscape);
$media->set_margins(array('left' => $page_margins[3], 'right' => $page_margins[1], 'top' => $page_margins[0], 'bottom' => $page_margins[2]));
$media->set_pixels(1024);
$g_config = array('cssmedia' => 'print', 'scalepoints' => '1', 'renderimages' => true, 'renderlinks' => false, 'renderfields' => false, 'renderforms' => false, 'mode' => 'html', 'encoding' => '', 'debugbox' => false, 'pdfversion' => '1.4', 'smartpagebreak' => true, 'draw_page_border' => false, 'html2xhtml' => false, 'method' => 'fpdf', 'pages_limit' => $pages_limit);
$pipeline->configure($g_config);
$pipeline->process_batch(array(''), $media);
if (!$save_to_file) {
exit(0);
}
}
示例8: array
$GLOBALS['g_config'] = array('compress' => isset($_REQUEST['compress']), 'cssmedia' => get_var('cssmedia', $_REQUEST, 255, "screen"), 'debugbox' => isset($_REQUEST['debugbox']), 'debugnoclip' => isset($_REQUEST['debugnoclip']), 'draw_page_border' => isset($_REQUEST['pageborder']), 'encoding' => get_var('encoding', $_REQUEST, 255, ""), 'html2xhtml' => !isset($_REQUEST['html2xhtml']), 'imagequality_workaround' => isset($_REQUEST['imagequality_workaround']), 'landscape' => isset($_REQUEST['landscape']), 'margins' => array('left' => (int) get_var('leftmargin', $_REQUEST, 10, 0), 'right' => (int) get_var('rightmargin', $_REQUEST, 10, 0), 'top' => (int) get_var('topmargin', $_REQUEST, 10, 0), 'bottom' => (int) get_var('bottommargin', $_REQUEST, 10, 0)), 'media' => get_var('media', $_REQUEST, 255, "A4"), 'method' => get_var('method', $_REQUEST, 255, "fpdf"), 'mode' => 'html', 'output' => get_var('output', $_REQUEST, 255, ""), 'pagewidth' => (int) get_var('pixels', $_REQUEST, 10, 800), 'pdfversion' => get_var('pdfversion', $_REQUEST, 255, "1.2"), 'ps2pdf' => isset($_REQUEST['ps2pdf']), 'pslevel' => (int) get_var('pslevel', $_REQUEST, 1, 3), 'renderfields' => isset($_REQUEST['renderfields']), 'renderforms' => isset($_REQUEST['renderforms']), 'renderimages' => isset($_REQUEST['renderimages']), 'renderlinks' => isset($_REQUEST['renderlinks']), 'scalepoints' => isset($_REQUEST['scalepoints']), 'smartpagebreak' => isset($_REQUEST['smartpagebreak']), 'transparency_workaround' => isset($_REQUEST['transparency_workaround']));
// dwildt, 110725
//var_dump($GLOBALS['g_config']);
//return;
$proxy = get_var('proxy', $_REQUEST, 255, '');
// 110723, dwildt +
if ($this->b_drs_perform) {
$endTime = $this->TT->getDifferenceToStarttime();
t3lib_div::devLog('[INFO/PERFORMANCE] html2ps is parsing the config file: ' . ($endTime - $this->startTime) . ' ms', $this->extKey, 0);
}
// 110723, dwildt +
// ========== Entry point
// 110723, dwildt -
//parse_config_file('../html2ps.config');
// 110723, dwildt +
parse_config_file(HTML2PS_DIR . 'html2ps.config');
// validate input data
if ($GLOBALS['g_config']['pagewidth'] == 0) {
die("Please specify non-zero value for the pixel width!");
}
// 110723, dwildt +
if ($this->b_drs_perform) {
$endTime = $this->TT->getDifferenceToStarttime();
t3lib_div::devLog('[INFO/PERFORMANCE] html2ps is starting the process: ' . ($endTime - $this->startTime) . ' ms', $this->extKey, 0);
}
// 110723, dwildt +
// begin processing
$g_media = Media::predefined($GLOBALS['g_config']['media']);
$g_media->set_landscape($GLOBALS['g_config']['landscape']);
$g_media->set_margins($GLOBALS['g_config']['margins']);
$g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
示例9: parse_config_file
<?php
require_once 'pipeline.class.php';
parse_config_file('html2ps.config');
$g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false);
$media = Media::predefined('A4');
$media->set_landscape(false);
$media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0));
$media->set_pixels(1024);
$g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels;
$g_pt_scale = $g_px_scale * 1.43;
$pipeline = new Pipeline();
$pipeline->fetchers[] = new FetcherURL();
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
$pipeline->parser = new ParserXHTML();
$pipeline->layout_engine = new LayoutEngineDefault();
$pipeline->output_driver = new OutputDriverFPDF($media);
$pipeline->destination = new DestinationFile(null);
$pipeline->process('http://localhost:81/testing/ww.html', $media);
示例10: isset
$mt = isset($POST_PROCESSING_DIRECTIVES["margin_top"]) ? $POST_PROCESSING_DIRECTIVES["margin_top"] : 0;
}
if ($mb == -1) {
$mb = isset($POST_PROCESSING_DIRECTIVES["margin_bottom"]) ? $POST_PROCESSING_DIRECTIVES["margin_bottom"] : 0;
}
// ** Overwrite page width value with directives
if ($pw == -1) {
$pw = isset($POST_PROCESSING_DIRECTIVES["page_width"]) ? $POST_PROCESSING_DIRECTIVES["page_width"] : 800;
}
/*****************************************************************************/
/** Configuration */
$GLOBALS['g_config'] = array('cssmedia' => "screen", 'media' => "A4", 'scalepoints' => true, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => $pw, 'landscape' => false, 'method' => "fpdf", 'margins' => array('left' => $ml, 'right' => $mr, 'top' => $mt, 'bottom' => $mb), 'encoding' => "", 'ps2pdf' => false, 'compress' => false, 'output' => 1, 'pdfversion' => "1.2", 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => false, 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true);
/*****************************************************************************/
/** Inizializza pipeline */
// ** Parse configuration file
parse_config_file(HTML2PS_BASEDIR . "html2ps.config");
// ** Media
$g_media = Media::predefined($GLOBALS['g_config']['media']);
$g_media->set_landscape($GLOBALS['g_config']['landscape']);
$g_media->set_margins($GLOBALS['g_config']['margins']);
$g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
// ** Pipeline
// *** Initialize the coversion pipeline
$pipeline = new Pipeline();
// *** Fetchers
$pipeline->fetchers[] = new FetcherUrl();
// *** Data filters
$pipeline->data_filters[] = new DataFilterDoctype();
$pipeline->data_filters[] = new DataFilterUTF8("");
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
// *** Parser
示例11: fn_init_pdf
/**
* Init pdf engine
*
* @return boolean always true
*/
function fn_init_pdf()
{
// pdf can't be generated correctly without DOM extension (DOMDocument class)
if (!class_exists('DOMDocument')) {
$msg = AREA == 'A' ? fn_get_lang_var('error_generate_pdf_admin') : fn_get_lang_var('error_generate_pdf_customer');
fn_set_notification('E', fn_get_lang_var('error'), $msg);
return false;
}
if (defined('PDF_STARTED')) {
return true;
}
define('CACHE_DIR', DIR_CACHE . 'pdf/cache');
define('OUTPUT_FILE_DIRECTORY', DIR_CACHE . 'pdf/out');
define('WRITER_TEMPDIR', DIR_CACHE . 'pdf/temp');
if (!is_dir('CACHE_DIR')) {
fn_mkdir(CACHE_DIR);
}
if (!is_dir('OUTPUT_FILE_DIRECTORY')) {
fn_mkdir(OUTPUT_FILE_DIRECTORY);
}
if (!is_dir('WRITER_TEMPDIR')) {
fn_mkdir(WRITER_TEMPDIR);
}
require DIR_CORE . 'class.pdf_converter.php';
parse_config_file(HTML2PS_DIR . 'html2ps.config');
fn_define('PDF_STARTED', true);
return true;
}
示例12: pdfThis
function pdfThis($html, $file_location = "", $pdfname)
{
global $config;
// set_include_path("../../../../library/pdf/");
require_once './library/pdf/config.inc.php';
require_once './library/pdf/pipeline.factory.class.php';
require_once './library/pdf/pipeline.class.php';
parse_config_file('./library/pdf/html2ps.config');
require_once "./include/init.php";
// for getInvoice() and getPreference()
#$invoice_id = $_GET['id'];
#$invoice = getInvoice($invoice_id);
#$preference = getPreference($invoice['preference_id']);
#$pdfname = trim($preference['pref_inv_wording']) . $invoice_id;
#error_reporting(E_ALL);
#ini_set("display_errors","1");
#@set_time_limit(10000);
/**
* Runs the HTML->PDF conversion with default settings
*
* Warning: if you have any files (like CSS stylesheets and/or images referenced by this file,
* use absolute links (like http://my.host/image.gif).
*
* @param $path_to_html String path to source html file.
* @param $path_to_pdf String path to file to save generated PDF to.
*/
if (!function_exists(convert_to_pdf)) {
function convert_to_pdf($html_to_pdf, $pdfname, $file_location = "")
{
global $config;
$destination = $file_location == "download" ? "DestinationDownload" : "DestinationFile";
/**
* Handles the saving generated PDF to user-defined output file on server
*/
if (!class_exists(MyFetcherLocalFile)) {
class MyFetcherLocalFile extends Fetcher
{
var $_content;
function MyFetcherLocalFile($html_to_pdf)
{
//$this->_content = file_get_contents($file);
$this->_content = $html_to_pdf;
}
function get_data($dummy1)
{
return new FetchedDataURL($this->_content, array(), "");
}
function get_base_url()
{
return "";
}
}
}
$pipeline = PipelineFactory::create_default_pipeline("", "");
// Attempt to auto-detect encoding
// Override HTML source
$pipeline->fetchers[] = new MyFetcherLocalFile($html_to_pdf);
$baseurl = "";
$media = Media::predefined($config->export->pdf->papersize);
$media->set_landscape(false);
global $g_config;
$g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderlinks' => true, 'renderfields' => true, 'renderforms' => false, 'mode' => 'html', 'encoding' => '', 'debugbox' => false, 'pdfversion' => '1.4', 'process_mode' => 'single', 'pixels' => $config->export->pdf->screensize, 'media' => $config->export->pdf->papersize, 'margins' => array('left' => $config->export->pdf->leftmargin, 'right' => $config->export->pdf->rightmargin, 'top' => $config->export->pdf->topmargin, 'bottom' => $config->export->pdf->bottommargin), 'transparency_workaround' => 1, 'imagequality_workaround' => 1, 'draw_page_border' => false);
$media->set_margins($g_config['margins']);
$media->set_pixels($config->export->pdf->screensize);
/*
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Location: $myloc");
*/
global $g_px_scale;
$g_px_scale = mm2pt($media->width() - $media->margins['left'] - $media->margins['right']) / $media->pixels;
global $g_pt_scale;
$g_pt_scale = $g_px_scale * 1.43;
$pipeline->configure($g_config);
$pipeline->data_filters[] = new DataFilterUTF8("");
$pipeline->destination = new $destination($pdfname);
$pipeline->process($baseurl, $media);
}
}
//echo "location: ".$file_location;
convert_to_pdf($html, $pdfname, $file_location);
}
示例13: fix_links_callback
//---------------------------- make links absolute --------------
function fix_links_callback($matches)
{
return $matches[1] . t3lib_div::locationHeaderUrl($matches[2]) . $matches[3];
}
$GLOBALS[TSFE]->content = preg_replace_callback('/(<a [^>]*href=\\")(?!#)(.*?)(\\")/', 'fix_links_callback', $GLOBALS[TSFE]->content);
$GLOBALS[TSFE]->content = preg_replace_callback('/(<form [^>]*action=\\")(?!#)(.*?)(\\")/', 'fix_links_callback', $GLOBALS[TSFE]->content);
// write the html for debugging puposes
if (0) {
# $fd=fopen('typo3temp/html2ps.html', 'wb');
# fwrite($fd,$GLOBALS{TSFE}->content);
# fclose($fd);
}
//------------------------------------------
// now pipe the html through html2ps
parse_config_file(t3lib_extMgm::extPath('pdf_generator2', 'html2ps/html2ps.config'));
$pdffile = tempnam('typo3temp', 'pdf_');
$pipeline = PipelineFactory::create_default_pipeline("", "");
// Override HTML source, passsing our original root directory
$pipeline->fetchers = array(new MyFetcherLocalFile());
// Override destination to local file
$pipeline->destination = new MyDestinationFile($pdffile);
if (preg_match('/^(\\d+(\\.\\d+)?)x(\\d+(\\.\\d+)?)$/i', $html2pdf_size, $match)) {
$media = new Media(array('width' => $match[1], 'height' => $match[3]), array('top' => 0, 'bottom' => 0, 'left' => 0, 'right' => 0));
} else {
$media = Media::predefined($html2pdf_size);
}
$media->set_landscape($html2pdf_landscape);
$media->set_margins(array('left' => $html2pdf_left, 'right' => $html2pdf_right, 'top' => $html2pdf_top, 'bottom' => $html2pdf_bottom));
$media->set_pixels($html2pdf_browserwidth);
global $g_config;
示例14: generate
//.........这里部分代码省略.........
</xml><![endif]-->
<style>
<!--
@page WordSection1
{size:' . $media . ';
margin-left:' . $marginLeft . 'mm;
margin-right:' . $marginRight . 'mm;
margin-bottom:' . $marginBottom . 'mm;
margin-top:' . $marginTop . 'mm;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.WordSection1
{page:WordSection1;}
-->
</style>
</head>
<body>
<div class=WordSection1>');
fwrite($oFile, $sContent);
fwrite($oFile, "\n</div></body></html>\n\n");
fclose($oFile);
/* End - Create .doc */
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
/* Start - Create .pdf */
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/');
G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
require_once PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php';
require_once PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php';
parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
$GLOBALS['g_config'] = array('cssmedia' => 'screen', 'media' => 'Letter', 'scalepoints' => false, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => 800, 'landscape' => $sLandscape, 'method' => 'fpdf', 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15), 'encoding' => '', 'ps2pdf' => false, 'compress' => false, 'output' => 2, 'pdfversion' => '1.3', 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => isset($_REQUEST['pageborder']), 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true);
$GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties);
$g_media = Media::predefined($GLOBALS['g_config']['media']);
$g_media->set_landscape($GLOBALS['g_config']['landscape']);
$g_media->set_margins($GLOBALS['g_config']['margins']);
$g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
if (isset($GLOBALS['g_config']['pdfSecurity'])) {
if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "") {
$GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID);
}
if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "") {
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID);
}
$g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
require_once HTML2PS_DIR . 'pdf.fpdf.encryption.php';
}
$pipeline = new Pipeline();
if (extension_loaded('curl')) {
require_once HTML2PS_DIR . 'fetcher.url.curl.class.php';
$pipeline->fetchers = array(new FetcherURLCurl());
if (isset($proxy)) {
if ($proxy != '') {
$pipeline->fetchers[0]->set_proxy($proxy);
}
}
} else {
require_once HTML2PS_DIR . 'fetcher.url.class.php';
$pipeline->fetchers[] = new FetcherURL();
}
$pipeline->data_filters[] = new DataFilterDoctype();
$pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']);
if ($GLOBALS['g_config']['html2xhtml']) {
示例15: generateHtml2ps_pdf
public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array())
{
define("MAX_FREE_FRACTION", 1);
define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/');
G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
require_once PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php';
require_once PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php';
parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
$GLOBALS['g_config'] = array('cssmedia' => 'screen', 'media' => 'Letter', 'scalepoints' => false, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => 800, 'landscape' => $sLandscape, 'method' => 'fpdf', 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15), 'encoding' => '', 'ps2pdf' => false, 'compress' => true, 'output' => 2, 'pdfversion' => '1.3', 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => isset($_REQUEST['pageborder']), 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true);
$GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties);
$g_media = Media::predefined($GLOBALS['g_config']['media']);
$g_media->set_landscape($GLOBALS['g_config']['landscape']);
$g_media->set_margins($GLOBALS['g_config']['margins']);
$g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
if (isset($GLOBALS['g_config']['pdfSecurity'])) {
if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "") {
$GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID);
}
if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "") {
$GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID);
}
$g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
require_once HTML2PS_DIR . 'pdf.fpdf.encryption.php';
}
$pipeline = new Pipeline();
if (extension_loaded('curl')) {
require_once HTML2PS_DIR . 'fetcher.url.curl.class.php';
$pipeline->fetchers = array(new FetcherURLCurl());
if (isset($proxy)) {
if ($proxy != '') {
$pipeline->fetchers[0]->set_proxy($proxy);
}
}
} else {
require_once HTML2PS_DIR . 'fetcher.url.class.php';
$pipeline->fetchers[] = new FetcherURL();
}
$pipeline->data_filters[] = new DataFilterDoctype();
$pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']);
if ($GLOBALS['g_config']['html2xhtml']) {
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
} else {
$pipeline->data_filters[] = new DataFilterXHTML2XHTML();
}
$pipeline->parser = new ParserXHTML();
$pipeline->pre_tree_filters = array();
$header_html = '';
$footer_html = '';
$filter = new PreTreeFilterHeaderFooter($header_html, $footer_html);
$pipeline->pre_tree_filters[] = $filter;
if ($GLOBALS['g_config']['renderfields']) {
$pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields();
}
if ($GLOBALS['g_config']['method'] === 'ps') {
$pipeline->layout_engine = new LayoutEnginePS();
} else {
$pipeline->layout_engine = new LayoutEngineDefault();
}
$pipeline->post_tree_filters = array();
if ($GLOBALS['g_config']['pslevel'] == 3) {
$image_encoder = new PSL3ImageEncoderStream();
} else {
$image_encoder = new PSL2ImageEncoderStream();
}
switch ($GLOBALS['g_config']['method']) {
case 'fastps':
if ($GLOBALS['g_config']['pslevel'] == 3) {
$pipeline->output_driver = new OutputDriverFastPS($image_encoder);
} else {
$pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder);
}
break;
case 'pdflib':
$pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']);
break;
case 'fpdf':
$pipeline->output_driver = new OutputDriverFPDF();
break;
case 'png':
$pipeline->output_driver = new OutputDriverPNG();
break;
case 'pcl':
$pipeline->output_driver = new OutputDriverPCL();
break;
default:
die('Unknown output method');
}
if (isset($GLOBALS['g_config']['watermarkhtml'])) {
$watermark_text = $GLOBALS['g_config']['watermarkhtml'];
} else {
$watermark_text = '';
}
$pipeline->output_driver->set_watermark($watermark_text);
if ($watermark_text != '') {
$dispatcher =& $pipeline->getDispatcher();
}
if ($GLOBALS['g_config']['debugbox']) {
$pipeline->output_driver->set_debug_boxes(true);
}
if ($GLOBALS['g_config']['draw_page_border']) {
//.........这里部分代码省略.........