PHPPresentation
PHPPresentation copied to clipboard
How to set background img by Picture or texture fill?
Office 2007 has the background set which can use Picture or texture fill.
That way, I can use a small image and don't have to use the large image as a background.
I can't find in the documentation that option being available.
Could someone help? or this feature is not developed yet.
@forexgg Hi, Could you send me a PowerPoint file with this case, for analysis, please ?
Hi Progi1984,
Sure. I’ve attached sample.pptx and the current background images for that slide. Originally, the background was generated using Format Background → Picture or texture fill, but I haven’t been able to replicate that using PhpOffice\PhpPresentation. So I ended up using a full screenshot image as the background instead.
Also, here’s the code I’ve been using to add the background, for your reference.
//
================================================================================ // new PPTX //
$objPHPPowerPoint = new PhpPresentation();
// Set 16:9 layout
//
$pptLayout = new \PhpOffice\PhpPresentation\DocumentLayout();
$pptLayout->setDocumentLayout($pptLayout::LAYOUT_SCREEN_16X9);
$objPHPPowerPoint->setLayout($pptLayout);
// Create a master layout
//
$oMasterSlide_Book_Sermon_Title =
$objPHPPowerPoint->getAllMasterSlides()[0]; // Background Img //
$oBkgImageSlide = new Image();
$oBkgImageSlide->setPath(public_path().'/bg_Book_Sermon_Title.jpg');
$oMasterSlide_Book_Sermon_Title->setBackground($oBkgImageSlide);
// New Master Slide
$objPHPPowerPoint->createMasterSlide();
// Master Slide Content
//
$oMasterSlide_Content = $objPHPPowerPoint->getAllMasterSlides()[1];
$oBkgImageSlide = new Image();
$oBkgImageSlide->setPath(public_path().'/bg_Content.jpg');
$oMasterSlide_Content->setBackground($oBkgImageSlide);
On Wed, Aug 21, 2024 at 5:51 PM Progi1984 @.***> wrote:
@forexgg https://github.com/forexgg Hi, Could you send me a PowerPoint file with this case, for analysis, please ?
— Reply to this email directly, view it on GitHub https://github.com/PHPOffice/PHPPresentation/issues/489#issuecomment-2303247362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEBEMNSO5V6W5CEYJW7P2O3ZSUKWFAVCNFSM6AAAAABM46LYPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBTGI2DOMZWGI . You are receiving this because you were mentioned.Message ID: @.***>
sorry. forgot the attachments.
On Mon, Aug 4, 2025 at 4:11 PM Steven Zhang @.***> wrote:
Hi Progi1984,
Sure. I’ve attached sample.pptx and the current background images for that slide. Originally, the background was generated using Format Background → Picture or texture fill, but I haven’t been able to replicate that using PhpOffice\PhpPresentation. So I ended up using a full screenshot image as the background instead.
Also, here’s the code I’ve been using to add the background, for your reference.
//================================================================================ // new PPTX //
$objPHPPowerPoint = new PhpPresentation(); // Set 16:9 layout //
$pptLayout = new \PhpOffice\PhpPresentation\DocumentLayout(); $pptLayout->setDocumentLayout($pptLayout::LAYOUT_SCREEN_16X9); $objPHPPowerPoint->setLayout($pptLayout); // Create a master layout //
$oMasterSlide_Book_Sermon_Title =$objPHPPowerPoint->getAllMasterSlides()[0]; // Background Img //
$oBkgImageSlide = new Image();$oBkgImageSlide->setPath(public_path().'/bg_Book_Sermon_Title.jpg'); $oMasterSlide_Book_Sermon_Title->setBackground($oBkgImageSlide);
// New Master Slide $objPHPPowerPoint->createMasterSlide(); // Master Slide Content //
$oMasterSlide_Content = $objPHPPowerPoint->getAllMasterSlides()[1]; $oBkgImageSlide = new Image(); $oBkgImageSlide->setPath(public_path().'/bg_Content.jpg'); $oMasterSlide_Content->setBackground($oBkgImageSlide);On Wed, Aug 21, 2024 at 5:51 PM Progi1984 @.***> wrote:
@forexgg https://github.com/forexgg Hi, Could you send me a PowerPoint file with this case, for analysis, please ?
— Reply to this email directly, view it on GitHub https://github.com/PHPOffice/PHPPresentation/issues/489#issuecomment-2303247362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEBEMNSO5V6W5CEYJW7P2O3ZSUKWFAVCNFSM6AAAAABM46LYPWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBTGI2DOMZWGI . You are receiving this because you were mentioned.Message ID: @.***>