0

I'm trying to combine 2 different scripts

  1. Autoprint - http://www.fpdf.org/en/script/script36.php
  2. TFPDF - http://www.fpdf.org/en/script/script92.php

Each script is working on its own as expected but I want them to work together. I tried searching but there's no similar situation as what I am facing. I tried combining different classes as suggested here but couldn't get it to work.

This is what I tried:

require('fpdf/pdf_js.php');
require('fpdf/tfpdf.php');
class PDF_AutoPrint extends PDF_JavaScript
{
    function AutoPrint($printer='')
    {
        if($printer)
        {
            $printer = str_replace('\\', '\\\\', $printer);
            $script = "var pp = getPrintParams();";
            $script .= "pp.interactive = pp.constants.interactionLevel.full;";
            $script .= "pp.printerName = '$printer'";
            $script .= "print(pp);";
        }
        else
            $script = 'print(true);';
        $this->IncludeJS($script);
    }
}

$pdf = new tFPDF(new PDF_AutoPrint());

It is giving me this error:

Catchable fatal error: Object of class PDF_AutoPrint could not be converted to string

Any help would be greatly appreciated.

Lhen
  • 181
  • 3
  • 15

1 Answers1

0

Alter the PDF_JavaScript class to extend tFPDF instead of FPDF. Then, change your last line to: $pdf = new PDF_AutoPrint();

sql_dru
  • 301
  • 2
  • 11