Announcement

Collapse
No announcement yet.

[SOLVED] TCPDF already in SC8?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] TCPDF already in SC8?

    I got a message from Marcia, saying that TCPDF already available in sc8.

    But I doubt coz there is no doc, article saying how to develop report via TCPDF

    hope the developers can clarify

    Thanks

  • #2
    This is how I do it in SC7:
    (I use this to convert a html document into pdf)

    Code:
    .
    $myroot = $_SERVER["DOCUMENT_ROOT"];
    $docid={VIN}.".pdf";
    $myoutput = $_SERVER["DOCUMENT_ROOT"].'/temp';
    
    $lib= $myroot.$me.'/third/html2pdf/html2pdf.class.php';
    echo '<br>loading lib: '.$lib;
    echo '<br> writing to: '.$myoutput;
    echo '<br>';
    
    include ($lib);
    
    echo '<br> lib included';
    
    
    $template = str_replace('[$vin$]',{VIN},$template);
    // etc.etc.$template = str_replace('[$dealerpostcode$]',{DealerPostalCode},$template);
    
    $html2pdf=new HTML2PDF('P','A4','en');
    //$fontname = $html2pdf->pdf->addTTFfont('fonts/verdana.ttf', 'TrueTypeUnicode', '', 32);
    
    //$fontname = $html2pdf->addFont('verdana', '', 'verdana.ttf');
    
    //$html2pdf->setModeDebug();
    $html2pdf->WriteHTML($template);
    $html2pdf->Output($myoutput.'/'.$docid,'D');
    
    //echo $template;
    echo "PDF file has been generated successfully!";
    If SC8 supports tcpdf I hope they have eliminated fpdf. The whole pdf libraries in SC take about 40% of the full lib space!
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      hi Albert, i followed closely how you manage to generate report

      below are my code and, whenever i try run report, it return blank..

      [code]
      ================================================== ========
      $libDir = $_SERVER["DOCUMENT_ROOT"] . '/xlibs/html2pdf/';
      //$rptDir = $_SERVER["DOCUMENT_ROOT"] . '/reports/';
      $rptDir = $_SERVER["DOCUMENT_ROOT"];

      // echo $libDir . "<br>";
      // echo $rptDir . "<br>";

      // convert in PDF
      require_once($libDir.'html2pdf.class.php');



      $html2pdf=new HTML2PDF('P','A4','en');
      $template = "this is report content ...";

      $html2pdf->setModeDebug();
      $html2pdf->WriteHTML($template);

      // SC returned BLANK screen when execute with following statement
      $html2pdf->Output($rptDir.'/'.'my_first_report.pdf','D');'

      ================================================== ==================
      hit error one "$html2pdf->Output($rptDir.'/'.'my_first_report.pdf','D');'"
      how to troubleshoot?

      Comment


      • #4
        The blank screen might be ok, but it should give you the opportunity to download the pdf. So that's the strange part as the above code comes from one of our production systems... you might go into the tcpdf docs to see how you can create a physical file to see if it generates the pdf. It might be a rigts issue.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          I checked, "reports" directory rights is 755, so should be write-able and yet there is no PDF file generated

          My folder structure
          - sc8 - all sc8 files inside
          - xlibs/html2pdf - lib files inside
          - reports - where I intended to generate the files

          There shouldn't be any problem right?
          Last edited by weilies; 08-06-2014, 08:54 PM.

          Comment


          • #6
            Originally posted by weilies View Post
            I checked, "reports" directory rights is 755, so should be write-able and yet there is no PDF file generated

            My folder structure
            - sc8 - all sc8 files inside
            - xlibs/html2pdf - lib files inside
            - reports - where I intended to generate the files

            There shouldn't be any problem right?
            No, if the paths are set correct etc. It simply is working here well as well at our customers. Can't tell what's wrong in your instance :-(
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              is there any useful log i can generate or troubleshoot?

              Comment


              • #8
                Originally posted by weilies View Post
                is there any useful log i can generate or troubleshoot?
                You could try to look into xdebug. Of course you can look into the apache logs to see if there are errors. Try a blank application first to see if you can get it running at all. On the site of pdf2html as well as tcpdf there are a lot of samples.

                albert
                Albert Drent
                aducom software netherlands
                scriptcase partner, reseller, support and (turn-key) development
                www.scriptcase.eu / www.scriptcase.nl

                Comment


                • #9
                  there is an error_log generated in scriptcase/app/<my project>/<my app>/error_log
                  This log is meaningful enough to troubleshoot.
                  I am really sad with the support given from official site... speechless... terrible

                  Currently i required TCPDF rather than HTML2PDF (which latest update 2011)

                  could you explain why chinese characters shown correctly in TCPDF example and not in SC?
                  https://docs.google.com/document/d/1...it?usp=sharing


                  weilies

                  Comment


                  • #10
                    Originally posted by weilies View Post
                    there is an error_log generated in scriptcase/app/<my project>/<my app>/error_log
                    This log is meaningful enough to troubleshoot.
                    I am really sad with the support given from official site... speechless... terrible

                    Currently i required TCPDF rather than HTML2PDF (which latest update 2011)

                    could you explain why chinese characters shown correctly in TCPDF example and not in SC?
                    https://docs.google.com/document/d/1...it?usp=sharing


                    weilies
                    Most likely that has something to do with locale / character settings in SC. You could try to set them before using the library. I'm not sure actually. I live in the 'easy' countries where the standard settings apply.
                    Albert Drent
                    aducom software netherlands
                    scriptcase partner, reseller, support and (turn-key) development
                    www.scriptcase.eu / www.scriptcase.nl

                    Comment


                    • #11
                      I have no idea what kinda language setting to be set, I am designing my app to show like Chinese, Japanese most Asia pacific languages at least.

                      Hope senior could give some input if u done that before

                      Comment


                      • #12
                        marcia is doing a webinar regarding tcpdf. You could ask the question there. She useually has technicials around her to answer difficult questions. As the devs are Portuguese speaking she translates.
                        Albert Drent
                        aducom software netherlands
                        scriptcase partner, reseller, support and (turn-key) development
                        www.scriptcase.eu / www.scriptcase.nl

                        Comment


                        • #13
                          Finally i managed to make it work!
                          http://sc.astudion.com/sc8/app/project/RPT_TCPDF_HTML/

                          a bit long winded way, i need to write the multi-languages content into a UTF8 text file and use file_get_content to grab it and output via TCPDF
                          But it worked fortunately!

                          Comment


                          • #14
                            Please,change your topic tittle and add [solved]

                            Could be interesting to tell us about the workaround to make it working

                            Regards
                            /Giuseppe

                            Professional Scriptcase Services
                            Some Customers opinions

                            Comment


                            • #15
                              below are my code

                              Code:
                              // To get rid of error 'PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted'
                              ini_set('memory_limit', '-1');
                              
                              $libHomeDir = $_SERVER["DOCUMENT_ROOT"] . '/xlibs';
                              $reportHomeDir = $_SERVER["DOCUMENT_ROOT"] . '/reports';
                              
                              require_once($libHomeDir  . '/tcpdf/tcpdf.php');
                              
                              
                              // create new PDF document
                              $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                              
                              // set document information
                              $pdf->SetCreator(PDF_CREATOR);
                              $pdf->SetAuthor('Nicola Asuni');
                              $pdf->SetTitle('TCPDF Example 006');
                              $pdf->SetSubject('TCPDF Tutorial');
                              $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
                              
                              // set default header data
                              $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);
                              
                              // set header and footer fonts
                              $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
                              $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
                              
                              // set default monospaced font
                              $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
                              
                              // set margins
                              $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
                              $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
                              $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
                              
                              // set auto page breaks
                              $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                              
                              // set image scale factor
                              $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
                              
                              
                              // ---------------------------------------------------------
                              
                              // set font
                              $pdf->SetFont('dejavusans', '', 10);
                              $pdf->SetFont('cid0cs', '', 10);
                              
                              // add a page
                              $pdf->AddPage();
                              
                              $html = file_get_contents($libHomeDir . '/tcpdf/examples/data/utf8test2.txt', false);
                              
                              // output the HTML content
                              $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
                              
                              // reset pointer to the last page
                              $pdf->lastPage();
                              
                              // ---------------------------------------------------------
                              
                              //Close and output PDF document
                              $pdf->Output('example_006.pdf', 'I');
                              
                              //============================================================+
                              // END OF FILE
                              //============================================================+

                              Comment

                              Working...
                              X