Announcement

Collapse
No announcement yet.

Tcpdf

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

  • Tcpdf

    Hi!

    I am using TCPDF to download Case entity. But it only works if I use output with F, if I put another option such as D is not worth. Why?

    Work: $pdf->($name, 'F');

    Don't work: $pdf->($name, 'D');

    Thanks!

  • #2
    you need to use corect comand:

    $pdf->Output($name, 'D');

    The method first calls Close() if necessary to terminate the document.

    Comment


    • #3
      My Fail!! I wrote it as you say but it does not work. Other idea??

      Comment


      • #4
        can you describe what result you want to achieve?

        try this one:
        $pdf->Output($name, D);
        and
        $pdf->Output($name);

        Comment


        • #5
          I want the pdf to be opened in the browser, either through a download or because it is displayed. These two options would be worth me.

          The option $pdf->Output($name,D); and option $pdf->Output($name); do anything. Only works for me, these option: $pdf->Output($urlname, 'F');
          Understanding by $urlname the path and the name of the pdf file that is generated.

          I have also tried to use $urlname with D or use FD and are not worth.

          Other idea??

          Comment


          • #6
            I my case - works this one $pdf->Output($name);

            can you write full script code of pdf generated?

            Comment


            • #7
              I have these function:

              public function descargarPDF(array $params, $data)
              {
              //obtener los datos de la factura...
              $factura = $this->getEntityManager()->getRepository('Factura')->where(array(
              'id' => $data['id'],
              ))->findOne();

              //obtener los datos del cliente...
              $cliente = $this->getEntityManager()->getRepository('Account')->where(array(
              'id' =>$factura->get('accountId')
              ))->findOne();

              // create new PDF document
              $pdf = new \Espo\Core\Pdf\Tcpdf();

              //quita el header
              $pdf->setPrintHeader(false);

              // set document information
              $pdf->SetCreator(PDF_CREATOR);
              $pdf->SetAuthor('Asesoria');
              $pdf->SetTitle('Factura');
              $pdf->SetSubject('Factura');
              $pdf->SetKeywords('factura, pdf');

              // set default header data
              // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
              // $pdf->setFooterData(array(0,64,0), array(0,64,128));

              // 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 some language-dependent strings (optional)
              if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
              require_once(dirname(__FILE__).'/lang/eng.php');
              $pdf->setLanguageArray($l);
              }

              // ---------------------------------------------------------

              // set default font subsetting mode
              $pdf->setFontSubsetting(true);

              // Set font
              // dejavusans is a UTF-8 Unicode font, if you only need to
              // print standard ASCII chars, you can use core fonts like
              // helvetica or times to reduce file size.
              $pdf->SetFont('dejavusans', '', 12, '', true);

              // Add a page
              // This method has several options, check the source code documentation for more information.
              $pdf->AddPage();

              // set text shadow effect
              $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(691,691,691), 'opacity'=>1, 'blend_mode'=>'Normal'));

              // Esto es el "header de la factura."
              $html = '
              <table>
              <tr>
              <th><h1>Factura</h1></th>
              <th><h1></h1></th>
              </tr>
              <tr>
              <th> </th>
              <th>2147483647</th>
              </tr>
              <tr>
              <th>Calle...</th>
              <th>correo electronico</th>
              </tr>
              <tr>
              <th>CIF</th>
              </tr>
              </table>
              ';

              //se escribe el texto en el html
              $pdf->writeHTML($html, true, false, false, false, '');

              //formatear fecha
              $fechaFormateada = date("d-m-Y", strtotime($factura->get("fecha")));

              //información del cliente
              $html = '
              <br/>
              <br/>
              <table>
              <tr>
              <th><b>Número</b></th>
              <th><b>Fecha</b></th>
              <th><b>Cliente</b></th>
              </tr>
              <tr>
              <td>'.$factura->get("numero").'</td>
              <td>'.$fechaFormateada.'</td>
              <td>'.$cliente->get("name").', '.$cliente->get("cif").', '.$cliente->get("billingAddressStreet").'</td>
              </tr>
              </table>
              ';

              //se escribe el texto en el html
              $pdf->writeHTML($html, true, false, false, false, '');

              // set font
              $pdf->SetFont('dejavusans', '', 8, '', true);
              //texto ley de protección de datos...
              $html = 'Esto es el texto de protección de datos... bla bla bla!';
              //se escribe el texto en el html
              $pdf->writeHTML($html, true, false, false, false, '');

              $nombre = 'Factura'.'-'.$factura->get("numero").'-'.$factura->get("fecha").'.pdf';
              $fichero = '/opt/lampp/htdocs/CRM/facturas/'.$nombre;
              // Output PDF
              $pdf->Output($fichero);
              }


              It's written in Spanish, ask me if you do not understand

              Thanks!

              Comment


              • #8
                try change this one

                $pdf->Output($fichero);

                to:

                $pdf->Output('testfilename');

                its must work

                I think problem in this rows:

                $nombre = 'Factura'.'-'.$factura->get("numero").'-'.$factura->get("fecha").'.pdf';
                $fichero = '/opt/lampp/htdocs/CRM/facturas/'.$nombre;

                Comment

                Working...
                X