承接 px-core/libre-office-converter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

px-core/libre-office-converter

Composer 安装命令:

composer require px-core/libre-office-converter

包简介

Converts files from one format, such as '.docx' or '.xlsx' to another, such as '.pdf' or '.csv'

README 文档

README

Symfony bundle to converts files from one format, such as '.docx' or '.xlsx' to another, such as '.pdf' or '.csv'.
Accepted formats: .docx .doc .xlsx .xls .ppt .pdf .csv .odt .odp .ods and much more

Authors

Requirements

Installation

Download the bundle using composer

$ composer require px-core/libre-office-converter "dev-master"

Composer will install the bundle to your project's vendor/px-core/libre-office-converter directory.

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new pxCore\LibreOfficeConverterBundle\pxCoreLibreOfficeConverterBundle()
        // ...
    );
}

If libreoffice is not installed yet use this command

$ sudo apt-get install libreoffice

Configure the libreoffice parameter (path to your libreoffice lib)

parameters:
    # ...
    libreoffice: /usr/bin/libreoffice	# Default value

On Unix or Linux variants the LibreOffice executable will usually be found in /usr/lib/libreoffice/program/soffice
(link: /usr/bin/libreoffice)

Usage

Exemple1: Convert WORD to PDF:

// Create a new instance of pxCore_libreOffice_converter_service 
$wordToPdfService = $this->get('pxCore_libreOffice_converter_service');

$webDir = __DIR__ . '/../../../../web';
// The word file path
$wordPath = $webDir . '/word/test.docx';
// The outDir in wich we will put the generated PDF
$outDir = $webDir . '/pdf';
$toFormat = 'pdf';
// Generate the PDF file
$wordToPdfService->convert($wordPath, $outDir, $toFormat);

Exemple2: Convert XLSX to CSV:

// Create a new instance of pxCore_libreOffice_converter_service 
$pxCoreLibreOfficeConverter = $this->get('pxCore_libreOffice_converter_service');

$webDir = __DIR__ . '/../../../../web';
// The xlsx file path
$xlsxPath = $webDir . '/xlsx/test2.xlsx';
// The outDir in wich we will put the generated csv file
$outdir = $webDir . '/csv';
$toFormat = 'csv';
// Generate the csv file
$pxCoreLibreOfficeConverter->convert($xlsxPath, $outdir, $toFormat);

Enjoy!

统计信息

  • 总下载量: 18.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-05