我有一个FlipBook jquery页面,需要显示太多的电子书(pdf格式)。我需要隐藏这些PDF文件,并使用PHP获取其内容并在我的FlipBook jquery页面上显示它们(而不是整个PDF,我想将其分成几部分)。
是否有任何方法可以用PHP获取PDF文件的全部内容?我需要根据它们的页面分开显示。
你可以使用PDF解析器(PHP PDF库)从PDF中提取一切内容。
PDF解析器库链接: https://github.com/smalot/pdfparser
在线演示链接: https://github.com/smalot/pdfparser/blob/master/doc/Usage.md
文档链接: https://github.com/smalot/pdfparser/tree/master/doc
示例代码:
<?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;
?>
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
?>
The [0]
means page 1
.