本文整理匯總了PHP中Zend_Pdf_ElementFactory::newStreamObject方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Pdf_ElementFactory::newStreamObject方法的具體用法?PHP Zend_Pdf_ElementFactory::newStreamObject怎麽用?PHP Zend_Pdf_ElementFactory::newStreamObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Pdf_ElementFactory
的用法示例。
在下文中一共展示了Zend_Pdf_ElementFactory::newStreamObject方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Object constructor.
*
* If resource is not a Zend_Pdf_Element object, then stream object with specified value is
* generated.
*
* @param Zend_Pdf_Element|string $resource
*/
public function __construct($resource)
{
$this->_processedFacories = array();
$this->_objectFactory = new Zend_Pdf_ElementFactory(1);
if ($resource instanceof Zend_Pdf_Element) {
$this->_resource = $this->_objectFactory->newObject($resource);
} else {
$this->_resource = $this->_objectFactory->newStreamObject($resource);
}
}
示例2: flush
/**
* Dump current drawing instructions into the content stream.
*
* @todo Don't forget to close all current graphics operations (like path drawing)
*
* @throws Zend_Pdf_Exception
*/
public function flush()
{
if ($this->_saveCount != 0) {
throw new Zend_Pdf_Exception('Saved graphics state is not restored');
}
if ($this->_contents == '') {
return;
}
if ($this->_pageDictionary->Contents->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
/**
* It's a stream object.
* Prepare Contents page attribute for update.
*/
$this->_pageDictionary->touch();
$currentPageContents = $this->_pageDictionary->Contents;
$this->_pageDictionary->Contents = new Zend_Pdf_Element_Array();
$this->_pageDictionary->Contents->items[] = $currentPageContents;
} else {
$this->_pageDictionary->Contents->touch();
}
$this->_pageDictionary->Contents->items[] = $this->_objFactory->newStreamObject($this->_contents);
$this->_contents == '';
}
示例3: __construct
//.........這裏部分代碼省略.........
fclose($imageFile);
$compressed = true;
$imageDataTmp = '';
$smaskData = '';
switch ($color) {
case Zend_Pdf_Image_Png::PNG_CHANNEL_RGB:
$colorSpace = new Zend_Pdf_Element_Name('DeviceRGB');
break;
case Zend_Pdf_Image_Png::PNG_CHANNEL_GRAY:
$colorSpace = new Zend_Pdf_Element_Name('DeviceGray');
break;
case Zend_Pdf_Image_Png::PNG_CHANNEL_INDEXED:
if (empty($paletteData)) {
throw new Zend_Pdf_Exception("PNG Corruption: No palette data read for indexed type PNG.");
}
$colorSpace = new Zend_Pdf_Element_Array();
$colorSpace->items[] = new Zend_Pdf_Element_Name('Indexed');
$colorSpace->items[] = new Zend_Pdf_Element_Name('DeviceRGB');
$colorSpace->items[] = new Zend_Pdf_Element_Numeric(strlen($paletteData) / 3 - 1);
$paletteObject = $this->_objectFactory->newObject(new Zend_Pdf_Element_String_Binary($paletteData));
$colorSpace->items[] = $paletteObject;
break;
case Zend_Pdf_Image_Png::PNG_CHANNEL_GRAY_ALPHA:
/*
* To decode PNG's with alpha data we must create two images from one. One image will contain the Gray data
* the other will contain the Gray transparency overlay data. The former will become the object data and the latter
* will become the Shadow Mask (SMask).
*/
if ($bits > 8) {
throw new Zend_Pdf_Exception("Alpha PNGs with bit depth > 8 are not yet supported");
}
$colorSpace = new Zend_Pdf_Element_Name('DeviceGray');
$decodingObjFactory = new Zend_Pdf_ElementFactory(1);
$decodingStream = $decodingObjFactory->newStreamObject($imageData);
$decodingStream->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
$decodingStream->dictionary->DecodeParms = new Zend_Pdf_Element_Dictionary();
$decodingStream->dictionary->DecodeParms->Predictor = new Zend_Pdf_Element_Numeric(15);
$decodingStream->dictionary->DecodeParms->Columns = new Zend_Pdf_Element_Numeric($width);
$decodingStream->dictionary->DecodeParms->Colors = new Zend_Pdf_Element_Numeric(2);
//GreyAlpha
$decodingStream->dictionary->DecodeParms->BitsPerComponent = new Zend_Pdf_Element_Numeric($bits);
$decodingStream->skipFilters();
$pngDataRawDecoded = $decodingStream->value;
//Iterate every pixel and copy out gray data and alpha channel (this will be slow)
for ($pixel = 0, $pixelcount = $width * $height; $pixel < $pixelcount; $pixel++) {
$imageDataTmp .= $pngDataRawDecoded[$pixel * 2];
$smaskData .= $pngDataRawDecoded[$pixel * 2 + 1];
}
$compressed = false;
$imageData = $imageDataTmp;
//Overwrite image data with the gray channel without alpha
break;
case Zend_Pdf_Image_Png::PNG_CHANNEL_RGB_ALPHA:
/*
* To decode PNG's with alpha data we must create two images from one. One image will contain the RGB data
* the other will contain the Gray transparency overlay data. The former will become the object data and the latter
* will become the Shadow Mask (SMask).
*/
if ($bits > 8) {
throw new Zend_Pdf_Exception("Alpha PNGs with bit depth > 8 are not yet supported");
}
$colorSpace = new Zend_Pdf_Element_Name('DeviceRGB');
$decodingObjFactory = new Zend_Pdf_ElementFactory(1);
$decodingStream = $decodingObjFactory->newStreamObject($imageData);
$decodingStream->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
$decodingStream->dictionary->DecodeParms = new Zend_Pdf_Element_Dictionary();