平头哥

平头哥

简单点

  • 财富值2000
  • 威望值30
  • 总积分2890

个人信息

  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    你这个最强
  • 2017-10-16 已签到
    连续签到1天,获得了5个金钱
  • 回复了 的说说
    linux命令全称,谁知道怎么或在哪查看?
    杯子不错哦,哈哈
  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    这项目挣钱不?跟卖煎饼的一样月入过万吗
  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    小心回家饭是凉的,b是热的,碗里没汤,b里有浆,哈哈
  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    真羡慕你家还有田
  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    养猪这行不行,我试过,哈哈
  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    什么鬼,乌索普?我还想做海贼王呢
  • 1.最好用xml的格式做模板。

    2.图片也可以替换,改类库
    public function setImg( $strKey, $img){

        $strKey = '${'.$strKey.'}';
        
        $relationTmpl = '<Relationship Id="RID" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/IMG"/>';
        $imgTmpl = '<w:pict><v:shape type="#_x0000_t75" style="position:absolute;left:0;text-align:left;margin-left:MLpt;margin-top:MTpt;width:WIDpx;height:HEIpx"><v:imagedata r:id="RID" o:title=""/></v:shape></w:pict>';
    
        $toAdd = $toAddImg = $toAddType = '';
        $aSearch = array('RID', 'IMG');
        $aSearchType = array('IMG', 'EXT');
        $countrels=$this->_countRels++;
        //I'm work for jpg files, if you are working with other images types -> Write conditions here
        $imgExt = 'jpg';
        $imgName = 'img' . $countrels . '.' . $imgExt;
    
        $this->zipClass->deleteName('word/media/' . $imgName);
        $this->zipClass->addFile($img['src'], 'word/media/' . $imgName);
    
        $typeTmpl = '<Override PartName="/word/media/'.$imgName.'" ContentType="image/EXT"/>';
    
        $rid = 'rId' . $countrels;
        $countrels++;
        list($w,$h) = getimagesize($img['src']);
    
        if(isset($img['swh'])) //Image proportionally larger side
        {
            if($w<=$h)
            {
               $ht=(int)$img['swh'];
               $ot=$w/$h;
               $wh=(int)$img['swh']*$ot;
               $wh=round($wh);
            }
            if($w>=$h)
            {
               $wh=(int)$img['swh'];
               $ot=$h/$w;
               $ht=(int)$img['swh']*$ot;
               $ht=round($ht);
            }
            $w=$wh;
            $h=$ht;
        }
    
        if(isset($img['size']))
        {
            $w = $img['size'][0];
            $h = $img['size'][1];           
        }
        if (isset($img['mt'])) {
            $mt = $img['mt'];
        }
        if (isset($img['ml'])) {
            $ml = $img['ml'];
        }
        $toAddImg .= str_replace(array('RID', 'WID', 'HEI','ML', 'MT'), array($rid, $w, $h,$ml, $mt), $imgTmpl) ;
        if(isset($img['dataImg']))
        {
            $toAddImg.='<w:br/><w:t>'.$this->limpiarString($img['dataImg']).'</w:t><w:br/>';
        }
    
        $aReplace = array($imgName, $imgExt);
        $toAddType .= str_replace($aSearchType, $aReplace, $typeTmpl) ;
    
        $aReplace = array($rid, $imgName);
        $toAdd .= str_replace($aSearch, $aReplace, $relationTmpl);
    
        $this->tempDocumentMainPart=str_replace('<w:t>' . $strKey . '</w:t>', $toAddImg, $this->tempDocumentMainPart);
    
        if($this->_rels=="")
        {
            $this->_rels=$this->zipClass->getFromName('word/_rels/document.xml.rels');
            $this->_types=$this->zipClass->getFromName('[Content_Types].xml');
        }
    
        $this->_types = str_replace('</Types>', $toAddType, $this->_types) . '</Types>';
        $this->_rels  = str_replace('</Relationships>', $toAdd, $this->_rels) . '</Relationships>';
    }
    
    
    

    $templateProcessor->setImg('IMG', array('src' => $model->img, 'swh' => '180', 'ml' => '45', 'mt' => '160'));

  • 回复了 的说说
    大家以后转行的想做啥,或者已经转行的在做啥,来扯扯犊子
    要不要来点瓜子
总监 等级规则
2890/5000
资料完整度
40/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

9

Ta的访客

76