PHP code example of fawno / php-wkhtmltox

1. Go to this page and download the library: Download fawno/php-wkhtmltox library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fawno / php-wkhtmltox example snippets


    use Fawno\PHPwkhtmltox\wkhtmltoimage;

  // Create wkhtmltoimage object (on Windows)
  //$wk = new wkhtmltoimage(__DIR__ . '/bin/wkhtmltox.dll');

  // Create wkhtmltoimage object (on Linux)
  $wk = new wkhtmltoimage('/usr/local/lib/wkhtmltox.so');

  // Set screen Width
  $wk->set_global_setting('screenWidth', '1200');

  // Set url to render
  $wk->set_global_setting('in', 'https://wkhtmltopdf.org/');

  // Set output format to PNG
  $wk->set_global_setting('fmt', 'png');

  // Render url and return image as string
  $data = $wk->convert();

  // Set output filename
  $wk->set_global_setting('out', 'wkhtmltopdf.png');

  // Render url
  $wk->convert();

  composer