且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PHP中将PDF转换为HTML?

更新时间:2023-01-23 10:51:11

1)下载.exe文件并将其解压缩到文件夹中:

1) download and unpack the .exe file to a folder: http://sourceforge.net/projects/pdftohtml/

2)创建一个.php文件,并放置以下代码(假设pdftohtml.exe位于该文件夹内,同时也包含源sample.pdf):

2) create a .php file, and put this code (assuming, that the pdftohtml.exe is inside that folder, and the source sample.pdf too):

<?php
$source_pdf="sample.pdf";
$output_folder="MyFolder";

    if (!file_exists($output_folder)) { mkdir($output_folder, 0777, true);}
$a= passthru("pdftohtml $source_pdf $output_folder/new_file_name",$b);
var_dump($a);
?>

3)输入 MyFolder ,您将看到转换后的文件(取决于页数.)

3) enter MyFolder, and you will see the converted files (depends on the number of pages..)

p.s.我不知道,但是也有很多商业或试用版api.

p.s. i dont know, but there exists many commercial or trial apis too.