定制 midi/document-converter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

midi/document-converter

最新稳定版本:v1.0.1

Composer 安装命令:

composer require midi/document-converter

包简介

office documents to pictures / pdf

README 文档

README

PHP Library for LibreOffice

Convert offices files to PDF or JPG or PNG using LibreOffice

Supported file types

pdf
pptx
ppt
docx
doc
wps
dotx
dotm
dot
odt
docm
ddt
xlsx
xls
log
txt

System Library Installation

brew install ghostscript
brew install ImageMagick
brew install pkg-config
pecl install imagick
brew install libreoffice
  • centos
yum install ghostscript
yum install ImageMagick
yum install pkg-config
pecl install imagick
yum install libreoffice
  • ubuntu
apt-get install ghostscript
apt-get install ImageMagick
apt-get install pkg-config
pecl install imagick
apt-get install libreoffice

Installation

Run this command within your project directory

composer require midi/document-converter

Usage

Here are some samples.

  • pdf converter to image array
$service = new DocumentConverter('/tmp/1.pdf');
$service->fileToImage()

// image save dir : /usr/tmp/a/dir
// image save ext : jpg
// image background : green
// image background : green
// read source file resolution : 100
// save image quality : 90
$service = new DocumentConverter('/tmp/1.pdf', '/usr/tmp/a/dir', 'jpg', 'green', 100, 90);
$service->fileToImage()
  • doc converter to image array
$service = new DocumentConverter('/tmp/1.docx');
$service->fileToImage()
  • doc/ppt converter to image array
$service = new DocumentConverter('/tmp/1.pptx');
$pdfPath = $service->fileToPdf()

Method Returns Result

  • fileToImage
[
    'total_page' => 4,
    'success_total' => 3,
    'fail_total' => 1,
    'success_page' => [
        '/tmp/1.jpg',
        '/tmp/2.jpg',
        '/tmp/4.jpg',
    ],
    'success_page' => [
        '/tmp/1.jpg',
        '/tmp/2.jpg',
    ],
    'fail_page' => [
        '/tmp/3.jpg',
    ]
]
  • fileToPdf
'/tmp/a/b/c/d/1.pdf'
  • Exception
DocumentConverterException

License

The OfficeConverter package is open-sourced software licensed under the MIT license.

Feedback & Contribute

Notify me of any issues, bugs, or improvements. Thanks.

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-11