• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Pdf_Trailer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Zend_Pdf_Trailer的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Trailer类的具体用法?PHP Zend_Pdf_Trailer怎么用?PHP Zend_Pdf_Trailer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Zend_Pdf_Trailer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

    /**
     * Object constructor
     *
     * @param Zend_Pdf_Element_Dictionary $dict
     * @param Zend_Pdf_Element_Reference_Context $context
     * @param Zend_Pdf_Trailer $prev
     */
    public function __construct(Zend_Pdf_Element_Dictionary $dict,
                                Zend_Pdf_Element_Reference_Context $context,
                                Zend_Pdf_Trailer $prev = null)
    {
        parent::__construct($dict);

        $this->_context = $context;
        $this->_prev    = $prev;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:16,代码来源:Keeper.php


示例2: __construct

 /**
  * Object constructor
  *
  * @param Zend_Pdf_Element_Dictionary $dict
  */
 public function __construct(Zend_Pdf_Element_Dictionary $dict)
 {
     parent::__construct($dict);
 }
开发者ID:be-dmitry,项目名称:zf1,代码行数:9,代码来源:Generator.php


示例3: render

 /**
  * Render the completed PDF to a string.
  * If $newSegmentOnly is true, then only appended part of PDF is returned.
  *
  * @param boolean $newSegmentOnly
  * @return string
  */
 public function render($newSegmentOnly = false)
 {
     $this->_dumpPages();
     // Check, that PDF file was modified
     // File is always modified by _dumpPages() now, but future implementations may eliminate this.
     if (!$this->_objFactory->isModified()) {
         if ($newSegmentOnly) {
             return '';
         } else {
             return $this->_trailer->getPDFString();
         }
     }
     // offset (from a start of PDF file) of new PDF file segment
     $segmentOffset = $this->_trailer->getPDFLength();
     // new PDF file segment itself
     $pdfSegment = '';
     // Last Object number in a list of free objects
     $lastFreeObject = $this->_trailer->getLastFreeObject();
     // Array of cross-reference table subsections
     $xrefTable = array();
     // Object numbers of first objects in each subsection
     $xrefSectionStartNums = array();
     // Last cross-reference table subsection
     $xrefSection = array();
     // Dummy initialization of the first element (specail case - header of linked list of free objects).
     $xrefSection[] = 0;
     $xrefSectionStartNums[] = 0;
     // Object number of last processed PDF object.
     // Used to manage cross-reference subsections.
     // Initialized by zero (specail case - header of linked list of free objects).
     $lastObjNum = 0;
     // Iterate objects to create new reference table
     foreach ($this->_objFactory->listModifiedObjects() as $updateInfo) {
         $objNum = $updateInfo->getObjNum();
         if ($objNum - $lastObjNum != 1) {
             // Save cross-reference table subsection and start new one
             $xrefTable[] = $xrefSection;
             $xrefSection = array();
             $xrefSectionStartNums[] = $objNum;
         }
         if ($updateInfo->isFree()) {
             // Free object cross-reference table entry
             $xrefSection[] = sprintf("%010d %05d f \n", $lastFreeObject, $updateInfo->getGenNum());
             $lastFreeObject = $objNum;
         } else {
             // In-use object cross-reference table entry
             $xrefSection[] = sprintf("%010d %05d n \n", $segmentOffset + strlen($pdfSegment), $updateInfo->getGenNum());
             $pdfSegment .= $updateInfo->getObjectDump();
         }
         $lastObjNum = $objNum;
     }
     // Save last cross-reference table subsection
     $xrefTable[] = $xrefSection;
     // Modify first entry (specail case - header of linked list of free objects).
     $xrefTable[0][0] = sprintf("%010d 65535 f \n", $lastFreeObject);
     $xrefTableStr = "xref\n";
     foreach ($xrefTable as $sectId => $xrefSection) {
         $xrefTableStr .= sprintf("%d %d \n", $xrefSectionStartNums[$sectId], count($xrefSection));
         foreach ($xrefSection as $xrefTableEntry) {
             $xrefTableStr .= $xrefTableEntry;
         }
     }
     $xrefStartOffset = $segmentOffset + strlen($pdfSegment);
     $this->_trailer->Size->value = $this->_objFactory->getObjectCount();
     $pdfSegment .= $xrefTableStr . $this->_trailer->toString() . "startxref\n" . $xrefStartOffset . "\n" . "%%EOF\n";
     if ($newSegmentOnly) {
         return $pdfSegment;
     } else {
         return $this->_trailer->getPDFString() . $pdfSegment;
     }
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:78,代码来源:Pdf.php


示例4: render

    /**
     * Render the completed PDF to a string.
     * If $newSegmentOnly is true and it's not a new document,
     * then only appended part of PDF is returned.
     *
     * @param boolean $newSegmentOnly
     * @param resource $outputStream
     * @return string
     * @throws Zend_Pdf_Exception
     */
    public function render($newSegmentOnly = false, $outputStream = null)
    {
        if ($this->_isNewDocument) {
            // Drop full document first time even $newSegmentOnly is set to true
            $newSegmentOnly = false;
            $this->_isNewDocument = false;
        }

        // Save document properties if necessary
        if ($this->properties != $this->_originalProperties) {
            $docInfo = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());

            foreach ($this->properties as $key => $value) {
                switch ($key) {
                    case 'Trapped':
                        switch ($value) {
                            case true:
                                $docInfo->$key = new Zend_Pdf_Element_Name('True');
                                break;

                            case false:
                                $docInfo->$key = new Zend_Pdf_Element_Name('False');
                                break;

                            case null:
                                $docInfo->$key = new Zend_Pdf_Element_Name('Unknown');
                                break;

                            default:
                                require_once 'Zend/Pdf/Exception.php';
                                throw new Zend_Pdf_Exception('Wrong Trapped document property vale: \'' . $value . '\'. Only true, false and null values are allowed.');
                                break;
                        }

                    case 'CreationDate':
                        // break intentionally omitted
                    case 'ModDate':
                        $docInfo->$key = new Zend_Pdf_Element_String((string)$value);
                        break;

                    case 'Title':
                        // break intentionally omitted
                    case 'Author':
                        // break intentionally omitted
                    case 'Subject':
                        // break intentionally omitted
                    case 'Keywords':
                        // break intentionally omitted
                    case 'Creator':
                        // break intentionally omitted
                    case 'Producer':
                        if (extension_loaded('mbstring') === true) {
                            $detected = mb_detect_encoding($value);
                            if ($detected !== 'ASCII') {
                                $value = "\xfe\xff" . mb_convert_encoding($value, 'UTF-16', $detected);
                            }
                        }
                        $docInfo->$key = new Zend_Pdf_Element_String((string)$value);
                        break;

                    default:
                        // Set property using PDF type based on PHP type
                        $docInfo->$key = Zend_Pdf_Element::phpToPdf($value);
                        break;
                }
            }

            $this->_trailer->Info = $docInfo;
        }

        $this->_dumpPages();
        $this->_dumpNamedDestinations();
        $this->_dumpOutlines();

        // Check, that PDF file was modified
        // File is always modified by _dumpPages() now, but future implementations may eliminate this.
        if (!$this->_objFactory->isModified()) {
            if ($newSegmentOnly) {
                // Do nothing, return
                return '';
            }

            if ($outputStream === null) {
                return $this->_trailer->getPDFString();
            } else {
                $pdfData = $this->_trailer->getPDFString();
                while ( strlen($pdfData) > 0 && ($byteCount = fwrite($outputStream, $pdfData)) != false ) {
                    $pdfData = substr($pdfData, $byteCount);
                }

//.........这里部分代码省略.........
开发者ID:nhp,项目名称:shopware-4,代码行数:101,代码来源:Pdf.php



注:本文中的Zend_Pdf_Trailer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_ProgressBar_Adapter类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Pdf_Style类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap