Download the PHP package garant/file-preview-generator-bundle without Composer

On this page you can find all versions of the php package garant/file-preview-generator-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package file-preview-generator-bundle

File Preview Generator Bundle

This bundle provides classes to generate preview image for office files like .doc, .docx, .xls and others. It contains client and server that let use the bundle both locally and remotely.

System requirements (for Microsoft Windows)

A) Microsoft Office must be installed. Also you need to configure COM-objects. From the Start menu, click Run and type Dcomcnfg.exe. In Component Services, click Console root, expand Component Services, expand Computers, then My Computer, then DCOM Configuration Find entity named Microsoft Word 97-2003 Document. Right click on it, then Properties. In the tab Identity choose This user and enter correct admin login and password. Save changes.

B) Install GhostScript

C) Install ImageMagic All _.dll file in folder modules/coders inside your ImageMagic directory copy to ImageMagic directory and C:\Windows\System32 and C:\Windows\SysWOW64 All _.dll file in folder modules/filters inside your ImageMagic directory copy to ImageMagic directory C:\Windows\System32 and C:\Windows\SysWOW64

D) Find and download archive php_imagick-3.4.1-7.0-ts-vc14-x64

Copy all CORE.dll's from it to C:\Windows\System32 and C:\Windows\SysWOW64

Copy php_imagick.dll to ext folder in your php directory

E) Add MAGICK_HOME to your environment PATH

F) Edit php.ini file in your php directory

Uncomment or add next lines in Windows extensions section:

extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_openssl.dll
extension=php_com_dotnet.dll
extension=php_imagick.dll

;...

memory_limit = 1024M

G) Reboot (here it's really important!)

Installation

With composer

This bundle can be installed using composer:

composer require garant/file-preview-generator-bundle

Register the bundle

<?php

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(

        // ...
        new Liip\ImagineBundle\LiipImagineBundle(),
        // ...
        new Garant\GarantFilePreviewGeneratorBundle\GarantFilePreviewGeneratorBundle(),
    );

    // ...
}

Configuration

You can add remote servers:

garant_file_preview_generator:
    #
    # Available algorithms: random, round_robin
    #server_select_algorithm: random
    #
    # Remote servers are used to generate file preview
    # To start generator server use "garant:file-preview-generator:server-start <server_name>" command
    #servers:
    #    local_unix:
    #        host: 0.0.0.0
    #        port: 9010
    #
    #    remote_windows:
    #        host: 192.168.10.201
    #        port: 9010
    #    
    #    remote_windows_secure:
    #        protocol: https 
    #        host: 192.168.10.201
    #        port: 9011

Optionally you can configure Liip imagine filters to post process preview images:

liip_imagine:
    filter_sets:
        avatar_square:
            filters:
                # Transforms 150x140 to 120x120, while cropping the width
                thumbnail: { size: [120, 120], mode: outbound }

Console commands

If remote server is configured you can start it. Call this command on remote server:

bin/console garant:file-preview-generator:server-start <server_name>

Also you can start server with -vvv flag to check memory usage and get other information about conversion process.

You can start some generators simultaneously and automatically restart processes using embedded supervisor:

bin/console garant:file-preview-generator:supervisor-start

Services

To generate preview you can use specific generator. Use the generator factory to create a generator that you need:

garant_file_preview_generator.remote_client - Remote client. 
garant_file_preview_generator.generator_factory - Factory service.

Example

$temp_file = new \SplFileObject('test.docx');

$factory = $this->container->get('garant_file_preview_generator.generator_factory');
$generator = $factory->get($temp_file, AbstractGenerator::PREVIEW_FORMAT_JPEG);
$jpeg_preview_file = $generator->generate($temp_file, AbstractGenerator::PREVIEW_FORMAT_JPEG);
if(!$jpeg_preview_file){
    $this->get('logger')->err('Preview attachment: Preview generation error');
    throw new \RuntimeException('Preview generation error');
}

dump($jpeg_preview_file);

// Generate filtered preview
$generator->setFilter('avatar_square');
$jpeg_preview_file = $generator->generate($temp_file, AbstractGenerator::PREVIEW_FORMAT_JPEG);

dump($jpeg_preview_file);

// Generate preview in PDF or other format
// see AbstractGenerator class constants
$generator = $factory->get($temp_file, AbstractGenerator::PREVIEW_FORMAT_PDF);
$pdf_preview_file = $generator->generate($temp_file, AbstractGenerator::PREVIEW_FORMAT_PDF);

// Optionally, you can convert range of pages
// $generator->setPageRange('0-2');
// Or set number of pages
// $generator->setPageCount(3);

dump($pdf_preview_file);

All versions of file-preview-generator-bundle with dependencies

PHP Build Version
Package Version
Requires ext-imagick Version *
php Version >=7.0
react/http Version dev-master
liip/imagine-bundle Version ^1.5
guzzle/http Version ^3.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package garant/file-preview-generator-bundle contains the following files

Loading the files please wait ....