} else {
$dest = str_replace('.' . $extension, '', $to);
}
- if (file_exists($cacheFile)) {
+ if (Files::isNotEmpty($cacheFile)) {
if (null === $to) {
return $cacheFile;
}
return $res;
}
+ /**
+ * @param $file
+ * @param $page
+ * @param $destfile
+ * @param $rect
+ * @param $invertPaper
+ * @return CommandLine
+ */
protected static function _pdftocairoRect($file, $page, $destfile, $rect, $invertPaper = false)
{
$pdftocairo = new CommandLine('pdftocairo');
$pdftocairo->setArg('-paperh', round($invertPaper ? $rect['width'] : $rect['height']));
self::_crop($pdftocairo, $page, $rect, 1, 1);
self::_exec($pdftocairo, $file, $destfile);
+ return $pdftocairo;
}
/**
public static function fixSVGDimensions($source, $preserveAspectRatio = "none")
{
$fixed = str_replace('.svg', '.f.svg', $source);
- if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) {
+ if (Files::isNotEmpty($fixed) && filemtime($fixed) >= filemtime($source)) {
return $fixed;
}
- if (file_exists($fixed) && is_link($fixed)) {
+ if (file_exists($fixed) && (is_link($fixed) || filesize($fixed) === 0)) {
unlink($fixed);
}
try {