I'm trying to use KnpLabs/KnpSnappyBundle, I want to know if i can :
My Controller
<?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');
}
}
Error :
The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [===> ] 5% [======> ] 10% Error: Failed loading page http://www.pdf995.com/samples/pdf.pdf (sometimes it will work just to ignore this error with --load-error-handling ignore) Error: Failed loading page http://www.africau.edu/images/default/sample.pdf (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1, due to unknown error. " stdout: "" command: /usr/bin/wkhtmltopdf --lowquality 'http://www.pdf995.com/samples/pdf.pdf' 'http://www.africau.edu/images/default/sample.pdf' 'merge.pdf'.
KnpLabs/KnpSnappyBundle provide tools to generate PDF from HTML, And also tools to generate Images. we can look for an other tool to merge pdfs like clegginabox/pdf-merger To convert pictures to PDF we can look for Setasign/FPDF