[英]PHP convert docx file to pdf
I am using PHP as a backend end, I generate a Docx
file on the backend and I want to send it to the frontend to make the user print it directly without downloading it.我使用 PHP 作为后端,我在后端生成一个
Docx
文件,我想将它发送到前端,让用户直接打印它而不下载它。
So I wanted to convert the Docx
file to PDF
and put it on the server so I can send its link to the frontend to make the user able to view it and print it.所以我想将
Docx
文件转换为PDF
并将其放在服务器上,这样我就可以将其链接发送到前端,以便用户能够查看并打印它。
But I am not able to convert from Docx
to pdf
, can anyone tell me an easy way to convert from Docx
to pdf
, or if anyone has an alternative way to do the whole process.但我无法从
Docx
转换为pdf
,谁能告诉我一种从Docx
转换为pdf
的简单方法,或者如果有人有另一种方法来完成整个过程。
I am using PHPWord
to generate the Docx
files from templates.我正在使用
PHPWord
从模板生成Docx
文件。
Attempts:尝试:
a) I tried to use PHPWord
to convert the Docx
file to an HTML
file but it generates a blank file. a) 我尝试使用
PHPWord
将Docx
文件转换为HTML
文件,但它会生成一个空白文件。
b) I tried to use COM
with OpenOffice
but the following error appeared: b) 我尝试将
COM
与OpenOffice
一起使用,但出现以下错误:
HTTP Error 500.0 - Internal Server Error.
HTTP 错误 500.0 - 内部服务器错误。 C:\php\php-cgi.exe - The FastCGI process exceeded configured request timeout
C:\php\php-cgi.exe - FastCGI 进程超过了配置的请求超时
c) I tried to use COM with Word.application
, but I received Access denied. c) 我尝试将 COM 与
Word.application
一起使用,但我收到拒绝访问。
Note: I am a beginner at PHP.注意:我是 PHP 的初学者。
You have a couple of choices:你有几个选择:
Also, you can check this article and build it on top of Azure serverless.此外,您可以查看这篇文章并将其构建在 Azure 无服务器之上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.