我正在尝试使用 KnpLabs/KnpSnappyBundle,我想知道我是否可以:
- 将pdf文件合并为一个
- 将图像转换为 pdf
- 在本地加载 pdf
我的控制器
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Knp\Snappy\Pdf;
use Symfony\Component\HttpKernel\KernelInterface;
class PdfController extends AbstractController
{
private $pdf;
private $kernel;
public function __construct(Pdf $pdf, KernelInterface $kernel)
{
$this->pdf = $pdf;
$this->kernel = $kernel;
}
/**
* @Route("pdf")
*/
public function pdfAction()
{
$html = "<html><body>hello snappy !</body></html>";
// trying to merge pdf -> error
$this->pdf->generate(['http://www.pdf995.com/samples/pdf.pdf', 'http://www.africau.edu/images/default/sample.pdf'], 'merge.pdf');
//trying to convert jpg to pdf -> it show empty PDF !
$this->pdf->generate('https://www.cleverfiles.com/howto/wp-content/uploads/2018/03/minion.jpg', 'jpgToPdf.pdf');
}
}
错误 :
退出状态代码“1”表示出了点问题:stderr:“正在加载页面(1/6)[>]0%[===>]5%[======>]10%错误:加载失败页面http://www.pdf995.com/samples/pdf.pdf(有时它会使用 --load-error-handling ignore 忽略此错误)错误:加载页面失败http://www.africau.edu /images/default/sample.pdf (有时它会使用 --load-error-handling ignore 忽略此错误)退出代码 1,由于未知错误。“标准输出:”“命令:/usr/bin/ wkhtmltopdf --lowquality ' http://www.pdf995.com/samples/pdf.pdf ' ' http://www.africau.edu/images/default/sample.pdf ' 'merge.pdf'。