]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 5 Oct 2012 15:53:35 +0000 (15:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 5 Oct 2012 15:53:35 +0000 (15:53 +0000)
inc/ws/Controlleur/class.ws.services.php
inc/ws/Metier/class.ws.book.parametres.php
js/pdfprint.js [new file with mode: 0644]
style/ws/printpdf.css [new file with mode: 0644]

index 78717f5ec0ee78e96f6734b4980b4485016c1ba5..e1cfc35a206615855912655661dfdba7493b70f6 100644 (file)
@@ -216,7 +216,12 @@ class wsServices extends cubeFlashGateway {
                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
@@ -226,7 +231,7 @@ class wsServices extends cubeFlashGateway {
                        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
@@ -255,29 +260,48 @@ class wsServices extends cubeFlashGateway {
                $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
index e86eee388c24f115f4e6600700e284ba2dafd1dc..d571f597b67842ca2d2ca547c98310de38e197ee 100644 (file)
@@ -109,7 +109,8 @@ class wsBookParametres extends wsParametres {
                $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
diff --git a/js/pdfprint.js b/js/pdfprint.js
new file mode 100644 (file)
index 0000000..60ed934
--- /dev/null
@@ -0,0 +1,31 @@
+$(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
diff --git a/style/ws/printpdf.css b/style/ws/printpdf.css
new file mode 100644 (file)
index 0000000..4a58c22
--- /dev/null
@@ -0,0 +1,11 @@
+*{
+       padding:0;
+       margin:0;
+}
+html,body{
+       height:100%;
+}
+
+body{
+       overflow: hidden;
+}
\ No newline at end of file