mikehaertl\pdftk\Pdf::send PHP Method

send() public method

Send PDF to client, either inline or as download (triggers PDF creation)
public send ( string | null $filename = null, boolean $inline = false ) : boolean
$filename string | null the filename to send. If empty, the PDF is streamed inline.
$inline boolean whether to force inline display of the PDF, even if filename is present.
return boolean whether PDF was created successfully
    public function send($filename = null, $inline = false)
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        $this->getTmpFile()->send($filename, $this->_tmpOutputContentType, $inline);
        return true;
    }

Usage Example

Exemplo n.º 1
0
 public function generate()
 {
     $pdf = new Pdf($this->_pdf);
     // Сложим рубли с копейками
     $num_sum1 = $this->_num_sum1 + $this->_num_sum1_kopeck;
     $num_sum2 = $this->_num_sum2 + $this->_num_sum2_kopeck;
     // echo  $this->_num_sum1_kopeck;exit;
     //Разобьём нужные нам числа
     $fromIndexSplit = Number::getSplitDigits($this->_from_index, 6);
     $toIndexSplit = Number::getSplitDigits($this->_to_index, 6);
     $fromInnSplit = Number::getSplitDigits($this->_from_inn, 12);
     $fromCorpPriceSplit = Number::getSplitDigits($this->_from_corp_price, 20);
     $fromCalcPriceSplit = Number::getSplitDigits($this->_from_calc_price, 20);
     $pdfParams = array('words_sum1' => Number::num2str($num_sum1), 'words_sum2' => Number::num2str($num_sum2), 'num_sum1' => $this->_num_sum1, 'num_sum2' => $this->_num_sum2, 'num_sum2_kopeck' => Number::fract($this->_num_sum2_kopeck), 'to_fio' => $this->_to_fio, 'to_addr' => $this->_to_addr, 'from_fio' => $this->_from_fio, 'from_addr' => $this->_from_addr);
     // Склеим ассоциативные массивы с друг другом
     $pdfParams = array_merge($pdfParams, $this->cookPrefixArray($fromIndexSplit, 'from_index_'), $this->cookPrefixArray($toIndexSplit, 'to_index_'), $this->cookPrefixArray($fromInnSplit, 'inn_'), $this->cookPrefixArray($fromCorpPriceSplit, 'corp_price_'), $this->cookPrefixArray($fromCalcPriceSplit, 'calc_price_'));
     // var_dump($pdfParams);
     $pdf->fillForm($pdfParams)->needAppearances();
     if ($err = $pdf->getError()) {
         return $err;
     }
     $pdf->send();
 }