【问题标题】:Recurly - Get invoice PDF (pdf from pdf string)Recurly - 获取发票 PDF(来自 pdf 字符串的 PDF)
【发布时间】:2013-10-04 13:10:38
【问题描述】:

我正在与 recurly 合作为我的客户开具账单。但是我怎样才能获得发票 pdf?
到目前为止,我有一张带有发票的表格。我显示发票的状态、计划、开始日期、结束日期。然后我也有这样的链接:

/user/invoicepdf/invoicenr/1502

链接转到我的 invoicepdfaction 并发送 invoicenr 参数。

在我的 invoicepdfaction 我有这个:

public function invoicepdfAction() {
    header('Content-Type:', 'application/pdf');
    header('Content-Disposition:', 'inline;');

    $request = $this->getRequest();
    $invoice_number = $request->getParam('invoicenr');

    try {
        $pdf = Recurly_Invoice::getInvoicePdf($invoice_number, 'en-US');
        var_dump($pdf);
    } catch (Recurly_NotFoundError $e) {
        print "Invoice not found.\n";
    }
}

我的 var_dump 显示 this

但是如何在浏览器中显示 pdf? (或者直接下载)

【问题讨论】:

    标签: php zend-framework pdf invoice recurly


    【解决方案1】:

    这通常对我有用:

    $request = $this->getRequest();
    $invoice_number = $request->getParam('invoicenr');
    
    try {
        header('Content-type: application/pdf');
        header('Accept-Language: en-US');
        header('Content-Disposition: attachment; filename="downloaded.pdf"');
    
        $pdf = Recurly_Invoice::getInvoicePdf($invoice_number, 'en-US');
        print($pdf);
    } catch (Recurly_NotFoundError $e) {
        print "Invoice not found.\n";
    }     
    

    您可以随时向 support@recurly.com 提交支持票,因为他们为其所有客户端库提供支持。

    【讨论】:

      【解决方案2】:

      应该是二进制 PDF 文件。您是否尝试将其保存到磁盘并在 Acrobat 或 Preview 中打开?

      我不确定 Zend 将如何让您返回它,但您应该能够将内容回显给用户。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-12
        • 2022-11-12
        • 1970-01-01
        相关资源
        最近更新 更多