I am creating HTML to PDF with MPDF. It is working awesome. The issue is that I am unable to create two PDFs at the same page. I want to generate two PDFs and both are to auto download and echo a message after the download. My code:
我正在使用MPDF创建HTML到PDF。它工作得很棒。问题是我无法在同一页面上创建两个PDF。我想生成两个PDF,两个都是自动下载并在下载后回显消息。我的代码:
$mpdf=new \mPDF('c','A4','','' , 0, 0, 0, 0, 0, 0);
$body='Hello One';
$mpdf->WriteHTML($body);
$mpdf->Output('demo.pdf','D');
// Second File
//第二个文件
$mpdftwo=new \mPDF('c','A4','','' , 0, 0, 0, 0, 0, 0);
$bodytwo='Hello Two';
$mpdftwo->WriteHTML($bodytwo);
$mpdftwo->Output('demotwo.pdf','D');
echo "Thank you" ;
1 个解决方案
#1
0
This is not possible with a single HTTP Request. You can do it either by executing separate async (eg AJAX) subrequests for each of downloaded files, or by eg. making an archive file of the PDF files and sending that archive to the user.
单个HTTP请求无法实现这一点。您可以通过为每个下载的文件执行单独的异步(例如AJAX)子请求,或者通过例如执行此操作。制作PDF文件的存档文件并将该存档发送给用户。
Also se this SO answer to the question on the same topic and this Q&A on why it is not possible to use plain HTTP to achieve what you want, at least not in every browser. To quote:
另外,对于同一主题的问题以及此问答解答为什么不可能使用普通HTTP来实现您想要的,至少不是在每个浏览器中。报价:
MIME/multipart is for email messages and/or POST transmission to the HTTP server. It was never intended to be received and parsed on the client side of a HTTP transaction. Some browsers do implement it, some others don't.
MIME / multipart用于向HTTP服务器发送电子邮件和/或POST。它从来没有打算在HTTP事务的客户端接收和解析。有些浏览器确实实现了它,有些则没有。
#1
0
This is not possible with a single HTTP Request. You can do it either by executing separate async (eg AJAX) subrequests for each of downloaded files, or by eg. making an archive file of the PDF files and sending that archive to the user.
单个HTTP请求无法实现这一点。您可以通过为每个下载的文件执行单独的异步(例如AJAX)子请求,或者通过例如执行此操作。制作PDF文件的存档文件并将该存档发送给用户。
Also se this SO answer to the question on the same topic and this Q&A on why it is not possible to use plain HTTP to achieve what you want, at least not in every browser. To quote:
另外,对于同一主题的问题以及此问答解答为什么不可能使用普通HTTP来实现您想要的,至少不是在每个浏览器中。报价:
MIME/multipart is for email messages and/or POST transmission to the HTTP server. It was never intended to be received and parsed on the client side of a HTTP transaction. Some browsers do implement it, some others don't.
MIME / multipart用于向HTTP服务器发送电子邮件和/或POST。它从来没有打算在HTTP事务的客户端接收和解析。有些浏览器确实实现了它,有些则没有。