本文整理汇总了PHP中Media::predefined方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::predefined方法的具体用法?PHP Media::predefined怎么用?PHP Media::predefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::predefined方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
function parse($value)
{
if ($value == '') {
return null;
}
// First attempt to create media with predefined name
if (preg_match('/^(\\w+)(?:\\s+(portrait|landscape))?$/', $value, $matches)) {
$name = $matches[1];
$landscape = isset($matches[2]) && $matches[2] == 'landscape';
$media =& Media::predefined($name);
if (is_null($media)) {
return null;
}
return array('size' => array('width' => $media->get_width(), 'height' => $media->get_height()), 'landscape' => $landscape);
}
// Second, attempt to create media with predefined size
$parts = preg_split('/\\s+/', $value);
$width_str = $parts[0];
$height_str = isset($parts[1]) ? $parts[1] : $parts[0];
$width = units2pt($width_str);
$height = units2pt($height_str);
if ($width == 0 || $height == 0) {
return null;
}
return array('size' => array('width' => $width / mm2pt(1) / pt2pt(1), 'height' => $height / mm2pt(1) / pt2pt(1)), 'landscape' => false);
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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);
}
示例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: convert_to_pdf
/**
* 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.
*/
function convert_to_pdf($path_to_html, $path_to_pdf)
{
$pipeline = PipelineFactory::create_default_pipeline("", "");
// Override HTML source
$pipeline->fetchers[] = new MyFetcherLocalFile($path_to_html);
$filter = new PreTreeFilterHeaderFooter("HEADER", "FOOTER");
$pipeline->pre_tree_filters[] = $filter;
// Override destination to local file
$pipeline->destination = new MyDestinationFile($path_to_pdf);
$baseurl = "";
$media = Media::predefined("A4");
$media->set_landscape(false);
$media->set_margins(array('left' => 0, 'right' => 0, 'top' => 10, 'bottom' => 10));
$media->set_pixels(1024);
global $g_config;
$g_config = array('cssmedia' => 'screen', 'scalepoints' => '1', 'renderimages' => true, 'renderlinks' => true, 'renderfields' => true, 'renderforms' => false, 'mode' => 'html', 'encoding' => '', 'debugbox' => false, 'pdfversion' => '1.4', 'draw_page_border' => false);
$pipeline->configure($g_config);
$pipeline->process($baseurl, $media);
}
示例8: convert_to_pdf
/**
* 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 HTML code to be converted
* @param $path_to_pdf String path to file to save generated PDF to.
* @param $base_path String base path to use when resolving relative links in HTML code.
*/
function convert_to_pdf($html, $path_to_pdf, $base_path = '')
{
$pipeline = PipelineFactory::create_default_pipeline('', '');
// Override HTML source
// @TODO: default http fetcher will return null on incorrect images
// Bug submitted by 'imatronix' (tufat.com forum).
$pipeline->fetchers[] = new MyFetcherMemory($html, $base_path);
// Override destination to local file
$pipeline->destination = new MyDestinationFile($path_to_pdf);
$baseurl = '';
$media =& Media::predefined('A4');
$media->set_landscape(false);
$media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0));
$media->set_pixels(1024);
global $g_config;
$g_config = array('cssmedia' => 'screen', 'scalepoints' => '1', 'renderimages' => true, 'renderlinks' => true, 'renderfields' => true, 'renderforms' => false, 'mode' => 'html', 'encoding' => '', 'debugbox' => false, 'pdfversion' => '1.4', 'draw_page_border' => false);
$pipeline->configure($g_config);
$pipeline->process_batch(array($baseurl), $media);
}
示例9: 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);
}
}
示例10: MyFetcherLocalFile
{
var $_content;
function MyFetcherLocalFile()
{
$this->_content = "Test<!--NewPage-->Test<pagebreak/>Test<?page-break>Test";
}
function get_data($dummy1)
{
return new FetchedDataURL($this->_content, array(), "");
}
function get_base_url()
{
return "";
}
}
$media = Media::predefined("A4");
$media->set_landscape(false);
$media->set_margins(array('left' => 0, 'right' => 0, 'top' => 0, 'bottom' => 0));
$media->set_pixels(1024);
$GLOBALS['g_config'] = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => false, 'renderlinks' => true, 'renderfields' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false);
$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->configure($GLOBALS['g_config']);
$pipeline->fetchers[] = new MyFetcherLocalFile();
// $pipeline->destination = new MyDestinationFile($pdf);
$pipeline->destination = new MyDestinationDownload($pdf);
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
$pipeline->pre_tree_filters = array();
$header_html = "test";
$footer_html = "test";
示例11: generate
//.........这里部分代码省略.........
<!--
@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']) {
$pipeline->data_filters[] = new DataFilterHTML2XHTML();
} else {
$pipeline->data_filters[] = new DataFilterXHTML2XHTML();
示例12: array
<?php
$urls = array('http://247realmedia.com', 'http://888.com', 'http://abetterinternet.com', 'http://adsense.google.com', 'http://allwomencentral.com/?r=sub', 'http://www.articlehub.com/add.html', 'http://aur.archlinux.org', 'http://bbc.co.uk', 'http://benews.net', 'http://casalemedia.com', 'http://cnn.com', 'http://www.codeguru.com/register.php', 'http://cra-arc.gc.ca/menu-e.html', 'http://crux.nu', 'http://cs.wisc.edu/~ghost/', 'http://distrowatch.com', 'http://dmoz.org/cgi-bin/apply.cgi?submit=Proceed&where=Business%2FEmployment%2FCareers&id=&lk=&loc=', 'http://download.com', 'http://ebay.com', 'http://ewizard.com', 'http://exactsearch.net', 'http://exitexchange.com', 'http://ezinearticles.com/submit', 'http://falkag.net', 'http://fedora.redhat.com', 'http://freebsd.org', 'http://freewho.com/expired/index.php', 'http://gentoo.org', 'http://geocities.com', 'http://www.getafreelancer.com/users/signup.php', 'http://gmail.com', 'http://go.com', 'http://google.co.in', 'http://google.com/about.html', 'http://google.com/froogle', 'http://google.com/services/', 'http://google.fi/fi', 'http://guru.com/pro/post_profile.cfm', 'http://hamster.sazco.net', 'http://www-128.ibm.com/developerworks/linux/library/l-proc.html', 'http://hotmail.com', 'http://indianrail.gov.in', 'http://internet-optimizer.com', 'http://jakpsatweb.cz/css/css-vertical-center-solution.html', 'http://jobsearch.monsterindia.com/advanced_job_search.html', 'http://johnlewis.com', 'http://kubuntu.org', 'http://lyrc.com.ar/en/add/add.php', 'http://microsoft.com', 'http://msn.com', 'http://myblog.de', 'http://myway.com', 'http://mywebsearch.com', 'http://net-offers.net', 'http://netscape.com', 'http://netvenda.com', 'http://offeroptimizer.com', 'http://onet.pl', 'http://opensuse.org', 'http://osnews.com', 'http://papajohns.com', 'http://partypoker.com', 'http://passport.com', 'http://php.net', 'http://pilger.carlton.com', 'http://priyank.one09.net', 'http://python.org/~guido/', 'http://realmedia.com', 'http://rentacoder.com', 'http://revenue.net', 'http://rubixlinux.org', 'http://sage.com/local/regionNorthAmerica.aspx', 'http://searchscout.com', 'http://search.ebay.in/ws/search/AdvSearch?sofindtype=13', 'http://services.princetonreview.com/register.asp?RUN=%2FstudentTools%2FstudentTool%2Easp&RCN=auth&RDN=1&ALD=http%3A%2F%2Ftestprep%2Eprincetonreview%2Ecom', 'http://smarty.php.net', 'http://stallman.org', 'http://stanton-finley.net/fedora_core_5_installation_notes.html', 'http://thefacebook.com', 'http://tickle.com', 'http://trafficmp.com', 'http://tufat.com', 'http://ubuntu.com', 'http://user.it.uu.se/~jan/html2ps.html', 'http://vianet.com.pl', 'http://website.in/domain.php', 'http://whenu.com', 'http://whitehouse.gov', 'http://whois.org/', 'http://en.wikipedia.org', 'http://en.wikipedia.org/w/index.php?title=Spangenhelm&action=edit', 'http://wolfram.com', 'http://www.xe.com/ucc', 'http://yahoo.com', 'http://yahoomail.com', 'http://edit.yahoo.com/config/eval_register', 'http://zango.com');
require_once dirname(__FILE__) . '/../config.inc.php';
require_once dirname(__FILE__) . '/../pipeline.class.php';
parse_config_file(dirname(__FILE__) . '/../html2ps.config');
$g_config = array('cssmedia' => 'screen', 'renderimages' => true, 'renderforms' => true, 'renderlinks' => true, 'mode' => 'html', 'debugbox' => false, 'draw_page_border' => false);
require_once dirname(__FILE__) . '/../config.inc.php';
require_once HTML2PS_DIR . 'pipeline.class.php';
require_once HTML2PS_DIR . 'fetcher.url.class.php';
parse_config_file(HTML2PS_DIR . '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;
foreach ($urls as $url) {
$url_file = str_replace('http://', '', $url);
$url_file = str_replace(':', '_', $url_file);
$url_file = str_replace('/', '_', $url_file);
$url_file = str_replace('.', '_', $url_file);
$pipeline = new Pipeline();
$pipeline->configure($g_config);
$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($url_file);
示例13: array
// Add HTTP protocol if none specified
if (!preg_match("/^https?:/", $g_baseurl)) {
$g_baseurl = 'http://' . $g_baseurl;
}
$g_css_index = 0;
// Title of styleshee to use (empty if no preferences are set)
$g_stylesheet_title = "";
$g_config = array('cssmedia' => isset($_REQUEST['cssmedia']) ? $_REQUEST['cssmedia'] : "screen", 'media' => isset($_REQUEST['media']) ? $_REQUEST['media'] : "A4", 'scalepoints' => isset($_REQUEST['scalepoints']), 'renderimages' => isset($_REQUEST['renderimages']), 'renderfields' => isset($_REQUEST['renderfields']), 'renderforms' => isset($_REQUEST['renderforms']), 'pslevel' => isset($_REQUEST['pslevel']) ? $_REQUEST['pslevel'] : 3, 'renderlinks' => isset($_REQUEST['renderlinks']), 'pagewidth' => isset($_REQUEST['pixels']) ? (int) $_REQUEST['pixels'] : 800, 'landscape' => isset($_REQUEST['landscape']), 'method' => isset($_REQUEST['method']) ? $_REQUEST['method'] : "fpdf", 'margins' => array('left' => isset($_REQUEST['leftmargin']) ? (int) $_REQUEST['leftmargin'] : 0, 'right' => isset($_REQUEST['rightmargin']) ? (int) $_REQUEST['rightmargin'] : 0, 'top' => isset($_REQUEST['topmargin']) ? (int) $_REQUEST['topmargin'] : 0, 'bottom' => isset($_REQUEST['bottommargin']) ? (int) $_REQUEST['bottommargin'] : 0), 'encoding' => isset($_REQUEST['encoding']) ? $_REQUEST['encoding'] : "", 'ps2pdf' => isset($_REQUEST['ps2pdf']), 'compress' => isset($_REQUEST['compress']), 'output' => isset($_REQUEST['output']) ? $_REQUEST['output'] : 0, 'pdfversion' => isset($_REQUEST['pdfversion']) ? $_REQUEST['pdfversion'] : "1.2", 'transparency_workaround' => isset($_REQUEST['transparency_workaround']), 'imagequality_workaround' => isset($_REQUEST['imagequality_workaround']), 'draw_page_border' => isset($_REQUEST['pageborder']), 'debugbox' => isset($_REQUEST['debugbox']), 'html2xhtml' => !isset($_REQUEST['html2xhtml']), 'mode' => 'html');
// ========== Entry point
parse_config_file('./html2ps.config');
// validate input data
if ($g_config['pagewidth'] == 0) {
die("Please specify non-zero value for the pixel width!");
}
// begin processing
$g_media = Media::predefined($g_config['media']);
$g_media->set_landscape($g_config['landscape']);
$g_media->set_margins($g_config['margins']);
$g_media->set_pixels($g_config['pagewidth']);
$g_px_scale = mm2pt($g_media->width() - $g_media->margins['left'] - $g_media->margins['right']) / $g_media->pixels;
if ($g_config['scalepoints']) {
$g_pt_scale = $g_px_scale * 1.43;
// This is a magic number, just don't touch it, or everything will explode!
} else {
$g_pt_scale = 1.0;
}
// Initialize the coversion pipeline
$pipeline = new Pipeline();
// Configure the fetchers
$pipeline->fetchers[] = new FetcherURL();
// Configure the data filters
示例14: fn_html_to_pdf
function fn_html_to_pdf($html, $name)
{
if (!fn_init_pdf()) {
fn_redirect(!empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : INDEX_SCRIPT);
}
$pipeline = PipelineFactory::create_default_pipeline('', '');
if (!is_array($html)) {
$html = array($html);
}
$pipeline->fetchers = array(new PdfFetcherMemory($html, Registry::get('config.current_location') . '/'), new FetcherURL());
$pipeline->destination = new PdfDestinationDownload($name);
$pipeline->data_filters = array(new DataFilterDoctype(), new DataFilterHTML2XHTML());
$media =& Media::predefined('A4');
$media->set_landscape(false);
$media->set_margins(array('left' => 20, 'right' => 20, 'top' => 20, 'bottom' => 0));
$media->set_pixels(600);
$_config = array('cssmedia' => 'print', 'scalepoints' => '1', 'renderimages' => true, 'renderlinks' => true, 'renderfields' => true, 'renderforms' => false, 'mode' => 'html', 'encoding' => 'utf8', 'debugbox' => false, 'pdfversion' => '1.4', 'draw_page_border' => false, 'smartpagebreak' => true);
$pipeline->configure($_config);
$pipeline->process_batch(array_keys($html), $media);
}
示例15: get_data
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;