BUG 10746 I added a validate to pdf size SOLVED

I added a validate to pdf size
This commit is contained in:
Brayan Osmar Pereyra Suxo
2013-02-13 15:22:37 -04:00
parent e5a78a7197
commit 7eae5741fe
5 changed files with 23 additions and 8 deletions

View File

@@ -88,6 +88,10 @@ function _fix_display_position_float(&$css_state) {
}
function &create_pdf_box(&$root, &$pipeline) {
if ( !(@function_exists($root->node_type)) ) {
throw new Exception("Pdf not created", 1);
}
switch ($root->node_type()) {
case XML_DOCUMENT_NODE:
// TODO: some magic from traverse_dom_tree

View File

@@ -137,7 +137,9 @@ define('HTML2PS_VERSION_MINOR', 0);
define('HTML2PS_SUBVERSON', 16);
define('MAX_UNPENALIZED_FREE_FRACTION', 0.25);
define('MAX_FREE_FRACTION', 0.5);
if (!defined('MAX_FREE_FRACTION')) {
define('MAX_FREE_FRACTION', 0.5);
};
define('MAX_PAGE_BREAK_HEIGHT_PENALTY', 10000);
define('MAX_PAGE_BREAK_PENALTY', 1000000);
define('FORCED_PAGE_BREAK_BONUS', -1000000);

View File

@@ -64,7 +64,7 @@ class DOMTree {
}
function node_type() {
return $this->domelement->nodeType;
return @$this->domelement->nodeType;
}
function &parent() {

View File

@@ -16,7 +16,7 @@ class TreeBuilder {
// Second - object-oriented interface
// Third - pure PHP XML parser
if (function_exists('domxml_open_mem')) { return domxml_open_mem($xmlstring); };
if (class_exists('DOMDocument')) { return DOMTree::from_DOMDocument(DOMDocument::loadXML($xmlstring)); };
if (class_exists('DOMDocument')) { return @DOMTree::from_DOMDocument(DOMDocument::loadXML($xmlstring)); };
if (file_exists(HTML2PS_DIR.'/classes/include.php')) {
require_once(HTML2PS_DIR.'classes/include.php');
import('org.active-link.xml.XML');

View File

@@ -1110,11 +1110,20 @@ class OutputDocument extends BaseOutputDocument
}
copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
$status = $pipeline->process(((isset($_SERVER['HTTPS']))&&($_SERVER['HTTPS']=='on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media);
copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
try {
$status = $pipeline->process(((isset($_SERVER['HTTPS']))&&($_SERVER['HTTPS']=='on') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media);
copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
} catch (Exception $e) {
if ($e->getMessage() == 'Pdf not created') {
include_once ("classes/model/AppDocument.php");
list($sFileUID,$docVersion) = explode('_',$sFilename);
$oAppDocument = new AppDocument ();
$oAppDocument->remove($sFileUID,$docVersion);
G::SendTemporalMessage (G::loadTranslation("ID_OUTPUT_NOT_GENERATE"), "Error");
}
}
}
/**