- Get link
- X
- Other Apps
persipan download wkthtm yg versi mana saja, kali ini saya pake versi 7z download di
di baris perintah ,
https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.mxe-cross-win32.7z
dan dokumentasinya di
Installation
With composer, require:
composer require knplabs/knp-snappy-bundle
jalankan perintah diatas
tunggu sampe beres lalu
tinggal pakai dengan menggunakan
use Knp\Snappy\Pdf;
di baris awal dan
$snappy->generate($input, $output);echo "berhasil genrate $output_name";
Generate an image from a URL
$container->get('knp_snappy.image')->generate('http://www.google.fr', '/path/to/the/image.jpg');
Generate a pdf document from a URL
$container->get('knp_snappy.pdf')->generate('http://www.google.fr', '/path/to/the/file.pdf');
Generate a pdf document from multiple URLs
$container->get('knp_snappy.pdf')->generate(array('http://www.google.fr', 'http://www.knplabs.com', 'http://www.google.com'), '/path/to/the/file.pdf');
Generate a pdf document from a twig view
$this->get('knp_snappy.pdf')->generateFromHtml(
$this->renderView(
'MyBundle:Foo:bar.html.twig',
array(
'some' => $vars
)
),
'/path/to/the/file.pdf'
);
Render an image as response from a controller
use Knp\Bundle\SnappyBundle\Snappy\Response\JpegResponse;
class SomeController
{
public function imageAction()
{
$html = $this->renderView('MyBundle:Foo:bar.html.twig', array(
'some' => $vars
));
return new JpegResponse(
$this->get('knp_snappy.image')->getOutputFromHtml($html),
'image.jpg'
);
}
}
Comments