protected $quality = 85;
+ protected $transparent = false;
+
protected $localBuffer = false;
/**
*/
protected $job;
- public function __construct($format = 'jpg', $resolution = 150, $quality = 85, $withGraphics = true, $withTexts = true, $version = 'html')
+ public function __construct($format = 'jpg', $resolution = 150, $quality = 85, $withGraphics = true, $withTexts = true, $transparent = false, $version = 'html')
{
$this->format = $format;
$this->resolution = $resolution;
$this->withGraphics = $withGraphics;
$this->withTexts = $withTexts;
$this->version = $version;
+ $this->transparent = $transparent && $format === 'png';
$this->setQuality($quality);
}
$minsize = 100;
}
- $res = $dir . self::getFilename($this->getPage(), $this->getFormat(), $this->getResolution(), $this->getQuality(), $this->isWithGraphics(), $this->isWithTexts(), $this->getVersion());
+ $res = $dir . self::getFilename($this->getPage(), $this->getFormat(), $this->getResolution(), $this->getQuality(), $this->isWithGraphics(), $this->isWithTexts(), $this->isTransparent(), $this->getVersion());
$do = false;
if (!file_exists($res) || filesize($res) < $minsize) {
return $res;
}
- public static function getFilename($page, $format = 'jpg', $resolution = 150, $quality = 85, $withGraphics = true, $withTexts = true, $version = 'html')
+ public static function getFilename($page, $format = 'jpg', $resolution = 150, $quality = 85, $withGraphics = true, $withTexts = true, $transparent = false, $version = 'html')
{
$res = '';
if ($format === 'svg') {
} else if (in_array($format, ['png', 'jpg'])) {
$q = ($format === 'jpg' && $quality !== 85) ? '-' . $quality : '';
+ $t = ($format === 'png' && $transparent) ? '-transparent' : '';
$prefix = $withTexts ? 't' : 'h';
if ($resolution === 'thumb') {
- $res = 'p' . $page . $q . '.' . $format;
+ $res = 'p' . $page . $q . $t . '.' . $format;
} else {
- $res = $prefix . $page . '-' . $resolution . $q . '.' . $format;
+ $res = $prefix . $page . '-' . $resolution . $q . $t . '.' . $format;
}
} else if ($format === 'swf') {
$res = 'p' . $page . '.' . $format;
PDFTools::makeMiniShot($this->getSplittedPDFPage(), $file, 1, $this->getFormat(), $this->getQuality());
} else {
$rr = $this->getVersion() === 'html' ? $this->getResolutionRatio() : $this->getMobileRatio();
- PDFTools::makeShotPNM($this->getSplittedPDFPage(), $file, 1, '', $this->getResolution() * $rr, $this->getQuality(), 4, $this->isWithTexts(), null, null, $this->getFormat());
+ PDFTools::makeShotPNM($this->getSplittedPDFPage(), $file, 1, '', $this->getResolution() * $rr, $this->getQuality(), 4, $this->isWithTexts(), $this->isTransparent(), null, null, $this->getFormat());
}
} else if ($this->getFormat() === 'swf') {
PDFTools::makeSWF($this->getSplittedPDFPage(), $file, 1, $this->getResolution(), $this->getQuality());
{
$this->quality = max(0, min(100, round((float)$quality)));
}
+
+
+ /**
+ * @param bool $transparent
+ */
+ public function setTransparent(bool $transparent): void
+ {
+ $this->transparent = $transparent;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isTransparent(): bool
+ {
+ return $this->transparent;
+ }
}