<?php
$pdf = __DIR__ . '/../pdf/bill_of_lading_template.pdf';
$out = __DIR__ . '/../cache/bill_of_lading_page1.png';

if (file_exists($out)) {
    header('Location: /smproduce/cache/bill_of_lading_page1.png');
    exit;
}

$img = new Imagick();
$img->setResolution(200,200);
$img->readImage($pdf.'[0]');
$img->setImageFormat('png');
$img->writeImage($out);
$img->clear();

header('Location: /smproduce/cache/bill_of_lading_page1.png');
