Skip to content

jianhuawang/laravel-pdf-to-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 

Repository files navigation

laravel-pdf-to-image

Convert pdf files to images for Laravel.

Laravel 框架下的 PDF 转图片工具包,

本包提供了Laravel 把pdf文件转换为图片的功能, 同时基于Laravel Storage 对生成的图片进行存储和管理。

功能列表:

  1. 按页转换PDF文件为图片,每页生成1张图片
  2. Convert every page of PDF fiel to one image.
  3. 保存到指定的存储空间
  4. Save images to disk of Storage
  5. 支持云存储(测试中)
  6. Save image to cloud disk.(Developing)
  7. 支持定时任务后台转换图片(开发中)
  8. Convert PDF file to images by cron task.(Developing)

依赖 Package dependencies

必须安装扩展包,You must install package imagick, 参考信息 more info: http://php.net/manual/en/book.imagick.php http://php.net/manual/en/imagick.setup.php

"ext-imagick" : "*",
"intervention/image": "^2.0",
"illuminate/support": "5.*"

执行 run: php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"
then: you will find a new file image.php in folder config. Change " 'driver' => 'gd' " to " 'driver' => 'imagick' "

安装Installation:

composer require jianhuawang/laravel-pdf-to-image:^0.4

Laravel >= 5.5, after install nothing left to do.
Laravel <5.5

Add a provider in providers array in config/app.php:
JianhuaWang\PdfToImage\PdfToImageMaker::class,
 Add a aliase in aliases array:
'PdfToImage'=>JianhuaWang\PdfToImage\PdfToImageFacade::class,

用法Usage:

  1. Following code will read pdf file on (project root) + /storage/app/test.pdf, and convert first page to image, the image will be saved on (project root) + /storage/app/(current date)/(seconds).jpg $pdfFileNameWithPath='test.pdf';     $converter=new JianhuaWang\PdfToImage\PdfToImageMaker($pdfFileNameWithPath);
      $converter->saveImage();// Default action is converting all pages to images.
    
  2. The following codes has same function with above.

    use PdfToImage; PdfToImage::pdfFile('test.pdf')->saveImage();

About

Convert pdf files to images for Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages