• <bdo id='GLpsT'></bdo><ul id='GLpsT'></ul>

      1. <tfoot id='GLpsT'></tfoot>

        <small id='GLpsT'></small><noframes id='GLpsT'>

        <i id='GLpsT'><tr id='GLpsT'><dt id='GLpsT'><q id='GLpsT'><span id='GLpsT'><b id='GLpsT'><form id='GLpsT'><ins id='GLpsT'></ins><ul id='GLpsT'></ul><sub id='GLpsT'></sub></form><legend id='GLpsT'></legend><bdo id='GLpsT'><pre id='GLpsT'><center id='GLpsT'></center></pre></bdo></b><th id='GLpsT'></th></span></q></dt></tr></i><div id='GLpsT'><tfoot id='GLpsT'></tfoot><dl id='GLpsT'><fieldset id='GLpsT'></fieldset></dl></div>

      2. <legend id='GLpsT'><style id='GLpsT'><dir id='GLpsT'><q id='GLpsT'></q></dir></style></legend>

      3. 将 2 pdf 与 Zend Framework 合并

        时间:2023-10-04

          <tbody id='jpPag'></tbody>
      4. <small id='jpPag'></small><noframes id='jpPag'>

          <bdo id='jpPag'></bdo><ul id='jpPag'></ul>
        • <i id='jpPag'><tr id='jpPag'><dt id='jpPag'><q id='jpPag'><span id='jpPag'><b id='jpPag'><form id='jpPag'><ins id='jpPag'></ins><ul id='jpPag'></ul><sub id='jpPag'></sub></form><legend id='jpPag'></legend><bdo id='jpPag'><pre id='jpPag'><center id='jpPag'></center></pre></bdo></b><th id='jpPag'></th></span></q></dt></tr></i><div id='jpPag'><tfoot id='jpPag'></tfoot><dl id='jpPag'><fieldset id='jpPag'></fieldset></dl></div>
          <tfoot id='jpPag'></tfoot><legend id='jpPag'><style id='jpPag'><dir id='jpPag'><q id='jpPag'></q></dir></style></legend>

                  本文介绍了将 2 pdf 与 Zend Framework 合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试合并 2 个 PDF,一个在我的服务器上(不是动态生成的),一个在合并前生成并且没有保存在服务器上的任何位置(我只希望我的客户端下载它).所以我只有pdf的内容.两种 PDF 具有相同的格式 (A4).

                  I'm trying to merge 2 PDF, one on my server (not dynamically generated) and one generated just before the merge and not saved anywhere on the server (I just want my client to download it). So I only have the pdf's content. Both PDF have the same format (A4).

                  合并后的文件将有 2 页,并且不会保存在服务器上.

                  The merged file will have 2 pages and won't be saved on server as well.

                  因为我使用的是 Zend Framework,所以我更喜欢它的解决方案(在网上找不到……)还有什么建议吗?

                  Since, I'm using Zend Framework, I would prefer a solution with it (can't find one online...) else any advice ?

                  (网上找到的常见解决方案,但不起作用)

                  因为人们懒得点击.无论如何,代码都在链接中,因为它是错误的并且不起作用.

                  Edit : because people are lazy to click. The code is in the link anyway since it's wrong and doesn't work.

                  我尝试了下面的脚本,但我得到了错误:

                  I try the script below, but I get the error:

                  未捕获的异常带有消息的Zend_Pdf_Exception"'页面附加到一个文档,但在另一个上下文中呈现

                  Uncaught exception 'Zend_Pdf_Exception' with message 'Page is attached to one documen, but rendered in context of another

                  推荐答案

                  好的,根据@Gordon 在我的问题中的评论的指导,我找到了解决方案.

                  Alright, with the guide from @Gordon 's comment in my question, I got a solution.

                  1. 您必须至少拥有 Zend Framework 1.11(我使用的是 1.9,第一个错误)(感谢对这个问题的第 3 条评论)
                  2. 您必须从要合并的 PDF 中clone 页面,否则,您的应用程序将打印一个错误(不言自明)(感谢 this slideshare 这对 Zend_Pdf 非常有趣)
                  3. 静态 PDF 必须是 PDF <= 1.4(我的是 1.6).Zend_Pdf 无法解析 PDF 版本 > 1.4
                  1. You must have at least Zend Framework 1.11 (I was in 1.9, first error) (found thanks to the 3rd comment to this question)
                  2. You must clone page from the PDF you want to merge, else, your application will print an error (self explanatory one) (found thanks to this slideshare which is very interesting for Zend_Pdf)
                  3. The static PDF must be a PDF <= 1.4 (mine was 1.6). Zend_Pdf can't parse PDF which version is > 1.4

                  我使用这个应用程序来转换我在 1.6 版中的静态文件到 1.4.

                  I used this application to convert the static files I had in version 1.6 to 1.4.

                  这是我有和工作的粗略代码(我知道它没有优化,我稍后会做;但它仍然有用)

                  Here's the rough code I have and work (I know it's not optimised, I'll do it later; but still, it can be useful)

                  $pdf2show = new Zend_Pdf();  // Initializing the merged PDF
                  $pdf1 = Zend_Pdf::parse($pdfContent, 1); // $pdfContent is the generated one, got the content...
                  $template = clone $pdf1->pages[0]; // cloning the page (a must do)
                  $page1 = new Zend_Pdf_Page($template); // Creating the first page of the merged PDF with the previous content
                  $pdf2show->pages[] = $page1; // Adding this page to the final PDF
                  $pdf2 = Zend_Pdf::load('urlToYourPDF.pdf'); // Loading the statif PDF
                  $template2 = clone $pdf2->pages[0]; // cloning the page (a must do)
                  $page2 = new Zend_Pdf_Page($template2); // Creating the second page of the merged PDF with the previous content
                  $pdf2show->pages[] = $page2; // Adding this page to the final PDF
                  sendToWebBrowser('title', $pdf2show->render());
                  

                  sendToWebBrowser 是将 PDF 内容发送到浏览器的函数,title 作为...标题.$pdf2show->render() 将合并的 PDF 内容生成为字符串.

                  sendToWebBrowser is a function sending the PDF content to browser with the title as... title. $pdf2show->render() produces the merged PDF content as a string.

                  这篇关于将 2 pdf 与 Zend Framework 合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过 PHP 将 3 个图像合并为 1 个图像? 下一篇:PHP - 如何使用 mPDF 合并 PDF

                  相关文章

                  最新文章

                  1. <small id='D8pds'></small><noframes id='D8pds'>

                    1. <i id='D8pds'><tr id='D8pds'><dt id='D8pds'><q id='D8pds'><span id='D8pds'><b id='D8pds'><form id='D8pds'><ins id='D8pds'></ins><ul id='D8pds'></ul><sub id='D8pds'></sub></form><legend id='D8pds'></legend><bdo id='D8pds'><pre id='D8pds'><center id='D8pds'></center></pre></bdo></b><th id='D8pds'></th></span></q></dt></tr></i><div id='D8pds'><tfoot id='D8pds'></tfoot><dl id='D8pds'><fieldset id='D8pds'></fieldset></dl></div>
                        <bdo id='D8pds'></bdo><ul id='D8pds'></ul>
                      <legend id='D8pds'><style id='D8pds'><dir id='D8pds'><q id='D8pds'></q></dir></style></legend>

                    2. <tfoot id='D8pds'></tfoot>