php phppowerpoint,PHPPowerPoint - 一个用于处理Microsoft PowerPoint Presentations的纯PHP库

0fc05ef920b510c801c3b604a1e716ae.png

68747470733a2f2f706f7365722e707567782e6f72672f7068706f66666963652f70687070726573656e746174696f6e2f762f737461626c652e706e6768747470733a2f2f7472617669732d63692e6f72672f5048504f66666963652f50485050726573656e746174696f6e2e7376673f6272616e63683d6d617374657268747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f5048504f66666963652f50485050726573656e746174696f6e2f6261646765732f6770612e73766768747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f5048504f66666963652f50485050726573656e746174696f6e2f6261646765732f636f7665726167652e73766768747470733a2f2f706f7365722e707567782e6f72672f7068706f66666963652f70687070726573656e746174696f6e2f646f776e6c6f6164732e706e6768747470733a2f2f706f7365722e707567782e6f72672f7068706f66666963652f70687070726573656e746174696f6e2f6c6963656e73652e706e6768747470733a2f2f696d672e736869656c64732e696f2f62616467652f4749545445522d6a6f696e253230636861742d677265656e2e737667

PHPPresentation is a library written in pure PHP that provides a set of classes to write to different presentation file formats, i.e. Microsoft Office Open XML (OOXML or OpenXML) or OASIS Open Document Format for Office Applications (OpenDocument or ODF).

PHPPresentation is an open source project licensed under the terms of LGPL version 3. PHPPresentation is aimed to be a high quality software product by incorporating continuous integration and unit testing. You can learn more about PHPPresentation by reading the Developers' Documentation and the API Documentation.

Read more about PHPPresentation:

Features

Create an in-memory presentation representation

Set presentation meta data (author, title, description, etc)

Add slides from scratch or from existing one

Supports different fonts and font styles

Supports different formatting, styles, fills, gradients

Supports hyperlinks and rich-text strings

Add images with different styles (positioning, rotation, shadow)

Set printing options (header, footer, page margins, paper size, orientation)

Set transitions between slides

Output to different file formats: PowerPoint 2007 (.pptx), OpenDocument Presentation (.odp), Serialized Presentation)

... and lots of other things!

Requirements

PHPPresentation requires the following:

Installation

Composer method

It is recommended that you install the PHPPresentation library through composer. To do so, add the following lines to your composer.json.

{

"require": {

"phpoffice/phppresentation": "dev-master"

}

}

Manual download method

Alternatively, you can download the latest release from the releases page.

In this case, you will have to register the autoloader.

(Register autoloading is required only if you do not use composer in your project.)

require_once 'path/to/PhpPresentation/src/PhpPresentation/Autoloader.php';

\PhpOffice\PhpPresentation\Autoloader::register();

You will also need to download the latest PHPOffice/Common release from its releases page.

And you will also have to register its autoloader, too.

require_once 'path/to/PhpOffice/Common/src/Common/Autoloader.php';

\PhpOffice\Common\Autoloader::register();

Getting started

The following is a basic usage example of the PHPPresentation library.

// with your own install

require_once 'src/PhpPresentation/Autoloader.php';

\PhpOffice\PhpPresentation\Autoloader::register();

require_once 'src/Common/Autoloader.php';

\PhpOffice\Common\Autoloader::register();

// with Composer

require_once 'vendor/autoload.php';

use PhpOffice\PhpPresentation\PhpPresentation;

use PhpOffice\PhpPresentation\IOFactory;

use PhpOffice\PhpPresentation\Style\Color;

use PhpOffice\PhpPresentation\Style\Alignment;

$objPHPPowerPoint = new PhpPresentation();

// Create slide

$currentSlide = $objPHPPowerPoint->getActiveSlide();

// Create a shape (drawing)

$shape = $currentSlide->createDrawingShape();

$shape->setName('PHPPresentation logo')

->setDescription('PHPPresentation logo')

->setPath('./resources/phppowerpoint_logo.gif')

->setHeight(36)

->setOffsetX(10)

->setOffsetY(10);

$shape->getShadow()->setVisible(true)

->setDirection(45)

->setDistance(10);

// Create a shape (text)

$shape = $currentSlide->createRichTextShape()

->setHeight(300)

->setWidth(600)

->setOffsetX(170)

->setOffsetY(180);

$shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER );

$textRun = $shape->createTextRun('Thank you for using PHPPresentation!');

$textRun->getFont()->setBold(true)

->setSize(60)

->setColor( new Color( 'FFE06B20' ) );

$oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');

$oWriterPPTX->save(__DIR__ . "/sample.pptx");

$oWriterODP = IOFactory::createWriter($objPHPPowerPoint, 'ODPresentation');

$oWriterODP->save(__DIR__ . "/sample.odp");

More examples are provided in the samples folder. You can also read the Developers' Documentation and the API Documentation for more detail.

Contributing

We welcome everyone to contribute to PHPPresentation. Below are some of the things that you can do to contribute:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值