在PHP中获取PDF文件的内容
我有一个FlipBook jQuery页面和太多电子书(pdf格式)无法显示.我需要隐藏这些PDF,以便使用PHP获取其内容并在我的FlipBook jquery页面中显示它. (而不是提供整个pdf,我希望将其作为一部分提供.)
I have a FlipBook jquery page and too many ebooks(pdf format) to display on it. I need to keep these PDF's hidden so that I would like to get its content with PHP and display it with my FlipBook jquery page. (instead of giving whole pdf I would like to give it as parts).
我可以通过PHP获取PDF文件的全部内容吗? 我需要根据他们的页面分开他们.
Is there any way i can get whole content of PDF file with PHP? I need to seperate them according to their pages.
您可以使用PDF解析器(PHP PDF库)提取每个 以及PDF的所有内容.
You can use PDF Parser (PHP PDF Library) to extract each and everything from PDF's.
PDF分析器库链接: http://www.pdfparser.org/
在线演示链接: http://www.pdfparser.org/demo
文档链接: http://www.pdfparser.org/documentation
示例代码:
<?php
// Include Composer autoloader if not already done.
include 'vendor/autoload.php';
// Parse pdf file and build necessary objects.
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile('document.pdf');
$text = $pdf->getText();
echo $text;
?>
关于您问题的另一部分:
Regarding another part of your Question:
如何将PDF页面转换为图像:
您需要 ImageMagick
和 [0]
表示page 1
.