代码之家  ›  专栏  ›  技术社区  ›  TheWebs

如何使用laravelpdf库在php中下载pdf文件?

  •  0
  • TheWebs  · 技术社区  · 6 年前

    所以这一点在 the library 但我不能让它工作。考虑以下几点:

        $pdf = PDF::loadView('modules.efapreports.pdf.invoice', [
            'invoiceData'   => $this->collection,
            'organization'  => $organization,
            'invoiceNumber' => $this->formFields['invoice_number'],
            'invoiceDate'   => $this->formFields['invoice_date'],
            'dueDate'       => $this->formFields['due_date'],
            'payementTerms' => $this->formFields['payment_terms'],
            'gst'           => 1.05,
        ]);
    
        $pdf->save(storage_path(
            'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
        ));
    
        $pdf->download(storage_path(
            'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
        ));
    

    2 回复  |  直到 6 年前
        1
  •  1
  •   Fabián Montero Rodríguez    6 年前
    return PDF::loadView('modules.efapreports.pdf.invoice', [
            'invoiceData'   => $this->collection,
            'organization'  => $organization,
            'invoiceNumber' => $this->formFields['invoice_number'],
            'invoiceDate'   => $this->formFields['invoice_date'],
            'dueDate'       => $this->formFields['due_date'],
            'payementTerms' => $this->formFields['payment_terms'],
            'gst'           => 1.05,
        ])->download();
    
        2
  •  0
  •   hamza shan    6 年前

    您可以使用包dompdf来解决与pdf相关的问题。 https://packagist.org/packages/dompdf/dompdf