GithubHelp home page GithubHelp logo

laravel-pdf-to-html's Introduction

Laravel - PDF to HTML

Latest Version on Packagist Total Downloads

Convert PDF to HTML by using pdftohtml on Your Laravel Apps. Special thanks to pdf-to-text (Spatie) package for inspiring this package.

Contents

Requirements

Behind the scene this package leverages pdftohtml. You can verify if the binary installed on your system by executing this command.

which pdftohtml

If it doesn't return the installed path of the binary, you can install the binary using the following command.

  • Ubuntu and Debian family
apt-get install poppler-utils
  • CentOS, Fedora, and RedHat family
yum install poppler-utils
  • Mac using brew
brew install poppler

Installation

You can install the package via composer:

composer require ibnuhalimm/laravel-pdf-to-html

Setting Up

Optionally, you can set the config in your .env file:

PDF_TO_HTML_PATH="/usr/bin/pdftohtml"
PDF_TO_HTML_OUTPUT_DIR="/var/www/html/app/public"
PDF_TO_HTML_INLINE_IMAGES=true

Usage

Set the file and get result

use Ibnuhalimm\LaravelPdfToHtml\Facades\PdfToHtml;

$sourceFile = '/path/to/your-file.pdf';
PdfToHtml::setFile($sourceFile)->result();

// It will return output file path
// e.g. : /var/www/html/storage/app/pdf-to-html/your-file.html

Save as the result file

use Ibnuhalimm\LaravelPdfToHtml\Facades\PdfToHtml;

$sourceFile = '/path/to/your-file.pdf';
PdfToHtml::setFile($sourceFile)
    ->saveAs('result-file')
    ->result();

// It will return output file path as
// e.g. : /var/www/html/storage/app/pdf-to-html/result-file.html

We can set config on-the-fly

use Ibnuhalimm\LaravelPdfToHtml\Facades\PdfToHtml;

$sourceFile = '/path/to/your-file.pdf';
PdfToHtml::setFile($sourceFile)
    ->setConfig([
        'bin_path' => '/usr/local/bin/pdftohtml',
        'output_dir' => public_path('/new-location'),
        'inline_images' => false
    ])
    ->result();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

laravel-pdf-to-html's People

Contributors

ibnuhalimm avatar gusdemayo avatar

Stargazers

Ashik Ahmed avatar

Watchers

James Cloos avatar  avatar

laravel-pdf-to-html's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.