首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用PHPPowerPoint调整幻灯片中图像的大小

用PHPPowerPoint调整幻灯片中图像的大小
EN

Stack Overflow用户
提问于 2018-03-27 19:20:29
回答 1查看 401关注 0票数 0

我正在使用PHPPowerPoint库生成一些powerpoint文件。问题是来自服务器的图像太大了,正在打破幻灯片的限制。下面是一些用于图像的代码:

代码语言:javascript
复制
if(file_exists($dir.$image)){
    // Add logo
    $shape = $slide->createDrawingShape();
    $shape->setName('PHPPowerPoint logo');
    $shape->setDescription('PHPPowerPoint logo');
    $shape->setPath($dir.$image);
    $shape->setWidth(310);
    $shape->setHeight(608);
    $shape->setOffsetX(330);  
    $shape->setOffsetY(70); 
    //$shape->setOffsetY(720 - 10 - 40);
    }

注意,Im已经设置了宽度和高度,但是图像并不尊重这些配置。有什么是我可以做的,使图像尊重大小,我需要或得到一个反应的行为?

编辑:这是函数createTemplateSlide的代码:

代码语言:javascript
复制
function createTemplatedSlide(PHPPowerPoint $objPHPPowerPoint, $dir, $image, $razao, $nome, $data, $contador)
{
    // Create slide
    $slide = $objPHPPowerPoint->createSlide();

    if(file_exists($dir.$image)){
    // echo("$contador) o arquivo: '".$dir.$image."' existe <br>");
    // Add logo
    $shape = $slide->createDrawingShape();
    $shape->setName('PHPPowerPoint logo');
    $shape->setDescription('PHPPowerPoint logo');
    $shape->setPath($dir.$image);
    $shape->setWidth(310);
    $shape->setHeight(608);
    $shape->setOffsetX(330);  
    $shape->setOffsetY(70); 
    //$shape->setOffsetY(720 - 10 - 40);
    }

    // Create a shape (text)
    // echo date('H:i:s') . " Create a shape (rich text)<br>";
    $shape = $slide->createRichTextShape();
    $shape->setHeight(60);
    $shape->setWidth(960);
    $shape->setOffsetX(0);
    $shape->setOffsetY(20);
    $shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER );

    $textRun = $shape->createTextRun($razao."  ".$data);
    $textRun->getFont()->setBold(true);
    $textRun->getFont()->setSize(16);
    $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '00000000' ) );

    for ($i=0; $i <23 ; $i++) { 
        $shape->createBreak();
    }

    $textRun = $shape->createTextRun(utf8_encode($nome));
    $textRun->getFont()->setBold(true);
    $textRun->getFont()->setSize(16);
    $textRun->getFont()->setColor( new PHPPowerPoint_Style_Color( '00000000' ) );


    // Return slide
    return $slide;
}
EN

回答 1

Stack Overflow用户

发布于 2018-03-28 14:51:27

根据@MadeInDreams的建议,我发现了以下主题:

Resize image in PHP

我在那里使用了解决方案和函数imagejpeg将新生成的映像复制到项目的某个文件夹。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49520884

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档