AddExtGState(array('ca'=>$alpha, 'CA'=>$alpha, 'BM'=>'/'.$bm));
$this->SetExtGState($gs);
}
function AddExtGState($parms)
{
$n = count($this->extgstates)+1;
$this->extgstates[$n]['parms'] = $parms;
return $n;
}
function SetExtGState($gs)
{
$this->_out(sprintf('/GS%d gs', $gs));
}
function _enddoc()
{
if(!empty($this->extgstates) && $this->PDFVersion<'1.4')
$this->PDFVersion='1.4';
parent::_enddoc();
}
function _putextgstates()
{
for ($i = 1; $i <= count($this->extgstates); $i++)
{
$this->_newobj();
$this->extgstates[$i]['n'] = $this->n;
$this->_out('<extgstates[$i]['parms'];
$this->_out(sprintf('/ca %.3F', $parms['ca']));
$this->_out(sprintf('/CA %.3F', $parms['CA']));
$this->_out('/BM '.$parms['BM']);
$this->_out('>>');
$this->_out('endobj');
}
}
function _putresourcedict()
{
parent::_putresourcedict();
$this->_out('/ExtGState <<');
foreach($this->extgstates as $k=>$extgstate)
$this->_out('/GS'.$k.' '.$extgstate['n'].' 0 R');
$this->_out('>>');
}
function _putresources()
{
$this->_putextgstates();
parent::_putresources();
}
}
$pdf = new AlphaPDF();
$pdf->AddPage();
$pageCount = $pdf->setSourceFile(__DIR__ . '/../tests/_files/pdfs/transparency/ex74.pdf');
$tplIdA = $pdf->importPage(1, 'CropBox', true);
$tplIdB = $pdf->importPage(1, 'CropBox', false);
$pdf->SetAlpha(.1);
$pdf->useTemplate($tplIdA, 40, 50, 100);
$pdf->useTemplate($tplIdB, 160, 50, 100);
$pdf->Output('alpha-test.pdf', 'F');
echo microtime(true) - $start;
echo "
";
var_dump(memory_get_peak_usage());
echo "
";
echo filesize('alpha-test.pdf');
?>