Bug in document right-margin when more than 1 page.
[fa-stable.git] / reporting / includes / pdf_report.inc
index 0fec40a9b406e7353def05ad8253159efcb55966..07d83546638daf144c956502eaedad4ad0ad6f72 100644 (file)
@@ -1,4 +1,14 @@
 <?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU Affero General Public License,
+       AGPL, as published by the Free Software Foundation, either version 
+       3 of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+***********************************************************************/
 /* $Revision$ */
 $page_security = 8;
 //include_once($path_to_root . "reporting/includes/class.pdf.inc");
@@ -351,7 +361,7 @@ class FrontReport extends Cpdf
        function NewLine($l=1, $np=0)
        {
                $this->row -= ($l * $this->lineHeight);
-               if ($np > 0 &&  $this->row < $this->bottomMargin + ($np * $this->lineHeight))
+               if ($this->row < $this->bottomMargin + ($np * $this->lineHeight))
                        $this->Header();
        }
 
@@ -361,7 +371,7 @@ class FrontReport extends Cpdf
 
                if ($pdf_debug == 1)
                {
-                       $pdfcode = $this->Output();
+                       $pdfcode = $this->Output('','S');
                        $pdfcode = str_replace("\n", "\n<br>", htmlspecialchars($pdfcode));
                        echo '<html><body>';
                        echo trim($pdfcode);
@@ -377,8 +387,6 @@ class FrontReport extends Cpdf
                else
                {
 
-                       $buf = $this->Output();
-                       $len = strlen($buf);
                        $dir =  $comp_path.'/'.user_company(). '/pdf_files';
                        //save the file
                        if (!file_exists($dir))
@@ -387,12 +395,8 @@ class FrontReport extends Cpdf
                        }
                        // do not use standard filenames or your sensitive company data 
                        // are world readable
-                       $fname = tempnam($dir, 'FA');
-                       rename($fname, $fname.'.pdf');
-                       $fname .= '.pdf';
-                       $fp = fopen($fname,'w');
-                       fwrite($fp,$buf);
-                       fclose($fp);
+                       $fname = $dir.'/'.uniqid('').'.pdf';
+                       $this->Output($fname, 'F');
                        if ($email == 1)
                        {
                                $emailtype = true;