小编Lar*_*rry的帖子

HTML2PDF页面大小

我正在使用PHP和HTML2PDF lib生成pdf文件.但我要做的是生成一个pdf文件,其pageSize(宽度/高度)为html内容大小.我怎样才能做到这一点?

我的HTML内容是:

<page format="432x240" orientation="L" backcolor="#FFFFFF" style="font: arial;">
<div class="image">
    <span class="firstname">$fname</span>
    <span class="lastname">$lname</span>
</div>
Run Code Online (Sandbox Code Playgroud)

图像类的CSS是:

position: relative;width: 100%; /* for IE 6 */ background-image: url(../img/test.png);height: 240px; width: 432px;top: 50%;
Run Code Online (Sandbox Code Playgroud)

我的PHP代码是:

$html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8', 0);
$html2pdf->pdf->SetDisplayMode('fullpage');

$contentTpl = $this->renderPartial('template_01', array('fname' => $firstname, 'lname' => $lastname), true);
            $html2pdf->writeHTML(utf8_encode($contentTpl));
Run Code Online (Sandbox Code Playgroud)

php html2pdf

7
推荐指数
1
解决办法
1万
查看次数

用PHP透明圆裁剪图像

我想使用PHP裁剪圆形图像,但似乎我的新图像有一些透明像素.当然,我只希望椭圆的外部区域具有背景透明

我的代码如下:

        $image = imagecreatetruecolor($this->dst_w, $this->dst_h);
        imagealphablending($image,true);
        imagecopy ( $image , $image_s , 0, 0, $this->src_x, $this->src_y, $this->dst_w, $this->dst_h );
        $mask = imagecreatetruecolor($this->src_x, $this->src_y);
        $mask = imagecreatetruecolor($this->dst_w, $this->dst_h);
        $transparent = imagecolorallocate($mask, 255, 0, 0);
        imagecolortransparent($mask, $transparent);
        imagefilledellipse($mask, $this->dst_w/2, $this->dst_h/2, $this->dst_w, $this->dst_h, $transparent);
        $red = imagecolorallocate($mask, 0, 0, 0);
        imagecopymerge($image, $mask, 0, 0, 0, 0, $this->dst_w, $this->dst_h,100);
        imagecolortransparent($image, $red);
        imagefill($image,0,0, $red);

        if ($ext=="jpg" || $ext=="jpeg") {
            imagejpeg($image, $this->croppedImage);
        } else if ($ext=="png") {
            imagepng($image, $this->croppedImage);
        }           
        imagedestroy($image);
        imagedestroy($mask);
        // <------- END …
Run Code Online (Sandbox Code Playgroud)

php gd image-processing

4
推荐指数
2
解决办法
1万
查看次数

从子数组mongo文档中删除元素

我试图从mongo文档中删除子数组元素.我的文档(记录)是这样的:

{
    "_id" : 1,
    ...,
    "team" : {
        "players" : [{
            "name" : "A B",
            "birthday" : new Date("11/11/1995")
          }, {
            "name" : "A C",
            "birthday" : new Date("4/4/1991")
          }],
        "matches" : [{
            "against" : "Team B",
            "matchDay" : new Date("11/16/2012 10:00:00")
          }]
      }
}
Run Code Online (Sandbox Code Playgroud)

现在我想从我的文档中删除"A B"播放器.我试过这个:

$result = $collection->update(
    array('_id' => 1), 
    array('$pull' => array('team.players.name' => 'A B'))
);
Run Code Online (Sandbox Code Playgroud)

结果似乎没问题

(
    [updatedExisting] => 1
    [n] => 1
    [connectionId] => 8
    [err] => 
    [ok] => 1
)
Run Code Online (Sandbox Code Playgroud)

但是播放器仍然存在于文档中.

谢谢!

php mongodb

4
推荐指数
1
解决办法
2802
查看次数

标签 统计

php ×3

gd ×1

html2pdf ×1

image-processing ×1

mongodb ×1