High-quality PDF to Word conversion in PHP?(在 PHP 中高质量的 PDF 到 Word 转换?)
问题描述
在 PHP 中将 PDF 文档转换为 Microsoft Word 格式的最佳方法是什么?这可以作为 PHP 脚本或调用 (Linux) 可执行文件(使用 proc_open()).它只需要相对较快并生成高质量的 Word 文档(97/2000/2003 格式).
What's the best way of converting PDF docs to Microsoft Word format in PHP? This can be either as a PHP script or calling a (Linux) executable (with proc_open()). It just needs to be relatively fast and produce quality Word documents (in 97/2000/2003 format).
商业软件没问题.
推荐答案
要阅读 PDF 文件,您需要安装 XPDF 包,其中包括pdftotext".安装 XPDF/pdftotext 后,运行以下 PHP 语句以获取 PDF 文本:
To read PDF files, you will need to install the XPDF package, which includes "pdftotext." Once you have XPDF/pdftotext installed, you run the following PHP statement to get the PDF text:
content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -');
获取内容后,下载PHPDOCX社区版,这样试试.
After getting the content, Download PHPDOCX Community version, try like this.
<?php
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$textInfo = $content;
$paramsTextInfo = array(
'val' => 1,
'i' => 'single',
'sz' => 8
);
$docx->addText($textInfo, $paramsTextInfo);
$docx->createDocx('report.docx');
?>
这篇关于在 PHP 中高质量的 PDF 到 Word 转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 PHP 中高质量的 PDF 到 Word 转换?


基础教程推荐
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 使用 PDO 转义列名 2021-01-01