return $terms;\r
}\r
\r
- public function exportpdf() {\r
+ public function printpdf() {\r
+ $this->outputXML = false;\r
+ $this->exportpdf(true);\r
+ }\r
+\r
+ public function exportpdf($print = false) {\r
global $core;\r
\r
$daoBook = new wsDAOBook($core->con);\r
return;\r
}\r
\r
- if (!$book->parametres->pdfComplex || !$book->parametres->pdf) {\r
+ if (!$book->parametres->pdfComplex && !$book->parametres->pdf && $book->parametres->printMode != 'pdf') {\r
return;\r
}\r
// Normalize range\r
$destURL = '/fluidbook/cache/exportpdf/' . $book->book_id . '/' . $fname;\r
// If result exists, don't make the pdf again\r
if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) {\r
+ \r
+ } else {\r
+ // Prepare the command line\r
+ $l = array('A=' . $baseDocument, 'cat');\r
+ foreach ($range as $page) {\r
+ if ($page < 1 || $page > $book->parametres->pages) {\r
+ continue;\r
+ }\r
+ $l[] = 'A' . $page;\r
+ }\r
+ $l[] = 'output';\r
+ $l[] = $destFile;\r
+\r
+ $args = implode(' ', $l);\r
+ // Execute the command line\r
+ $pdftk = new cubeCommandLine('pdftk');\r
+ $pdftk->setPath(CONVERTER_PATH);\r
+ $pdftk->setManualArg($args);\r
+ $pdftk->execute();\r
+ }\r
+\r
+ if (!$print) {\r
+ // Return the url of the resulting pdf\r
http::redirect($destURL);\r
exit;\r
+ } else {\r
+ $res = '<!DOCTYPE html><html><head>\r
+ <meta http-equiv="X-UA-Compatible" content="IE=8" /> \r
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>\r
+ <script type="text/javascript" src="/js/pdfprint.js"></script>\r
+ <link rel="stylesheet" type="text/css" href="/style/ws/printpdf.css" />\r
+ \r
+ </head>\r
+ <body>\r
+ <iframe id="pdf" name="pdff" src="' . $destURL . '" width="100%" height="100%"></iframe>\r
+ </body>\r
+ </html>';\r
+ fb($res);\r
+ ob_end_clean();\r
+ echo $res;\r
+ exit;\r
}\r
- // Prepare the command line\r
- $l = array('A=' . $baseDocument, 'cat');\r
- foreach ($range as $page) {\r
- if ($page < 1 || $page > $book->parametres->pages) {\r
- continue;\r
- }\r
- $l[] = 'A' . $page;\r
- }\r
- $l[] = 'output';\r
- $l[] = $destFile;\r
-\r
- $args = implode(' ', $l);\r
- // Execute the command line\r
- $pdftk = new cubeCommandLine('pdftk');\r
- $pdftk->setPath(CONVERTER_PATH);\r
- $pdftk->setManualArg($args);\r
- $pdftk->execute();\r
- // Return the url of the resulting pdf\r
- http::redirect($destURL);\r
- exit;\r
}\r
\r
public function grdfValidForm() {\r
$this->fields['print'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Activer l'impression"));\r
$this->fields['printMode'] = array('type' => 'combo', 'default' => 'vector', 'editable' => true, 'label' => __("Mode d'impression"),\r
'datas' => array(__('Bitmap') => 'bitmap',\r
- __('Vectoriel') => 'vector'));\r
+ __('Vectoriel') => 'vector',\r
+ __('PDF') => 'pdf'));\r
$this->fields['printCoverWithMarks'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Imprimer les couvertures avec les pages marquées"), 'grade' => 3);\r
$this->forms['print'] = array('label' => __('Impression'),\r
'fieldsnames' => array('print', 'printMode', 'printCoverWithMarks'));\r
--- /dev/null
+$(function() {
+ $("iframe").load(function() {
+ printPDF(this);
+ });
+
+ $("iframe").on('readystatechange', function() {
+ if (this.readyState === 'complete') {
+ printPDF(this);
+ }
+ });
+})
+function printPDF(iframe) {
+ if (iframe == undefined) {
+ iframe = document.getElementById('pdf');
+ }
+
+ setTimeout(function() {
+ try {
+ iframe.contentWindow.print();
+ } catch (err) {
+ }
+ }, 1500);
+}
+
+function fb(o) {
+ try {
+ console.log(o);
+ } catch (err) {
+
+ }
+}
\ No newline at end of file