Download the PHP package andrej-griniuk/cakephp-html-to-image-view without Composer
On this page you can find all versions of the php package andrej-griniuk/cakephp-html-to-image-view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrej-griniuk/cakephp-html-to-image-view
More information about andrej-griniuk/cakephp-html-to-image-view
Files in andrej-griniuk/cakephp-html-to-image-view
Package cakephp-html-to-image-view
Short Description HtmlToImageView plugin for CakePHP
License MIT
Homepage https://github.com/andrej-griniuk/cakephp-html-to-image
Informations about the package cakephp-html-to-image-view
HtmlToImageView plugin for CakePHP
This plugin renders html views as image (jpg or png) using wkhtmltoimage
command line utility from WkHtmlToPdf package.
Requirements
- CakePHP 3.5+
- wkhtmltoimage
Installation
You can install this plugin into your CakePHP application using Composer.
Usage
First of all you need to load the plugin in your bootstrap.php
This will enable jpeg
and png
extensions on any route. Alternatively you could load the plugin without 'routes' => true
and only enable extensions on the routes you would like.
Layout path and templates sub dir are img
, e.g. you'll need to create src/Template/Layout/img/defaut.ctp
for your image views and and image view template would be, for example, src/Template/Events/img/view.ctp
. Then simply call, for example, http://localhost/events/view.jpg
to render your view as image.
Default path to wkhtmltoimage
binary is /usr/bin/wkhtmltoimage
. You can change it by setting HtmlToImageView.binary
configuration variable:
You can pass some options to wkhtmltoimage
from your view via $this->viewOptions(['imageOptions' => [...])
. List of available options:
- crop-h - Set height for cropping
- crop-w - Set width for cropping
- crop-x - Set x coordinate for cropping
- crop-y - Set y coordinate for cropping
- format - Output file format (jpg/png)
- width - Set screen width, note that this is used only as a guide line (default 1024)
- height - Set screen height (default is calculated from page content)
- zoom - Zoom level
- quality - Output image quality (between 0 and 100) (default 94)
For example:
See the full documentation and installation instruction for wkhtmltoimage
at the project website
Bugs & Feedback
https://github.com/andrej-griniuk/cakephp-html-to-image-view/issues
License
Copyright (c) 2018, Andrej Griniuk and licensed under The MIT License.