承接 cobweb-is/laravel-snappy 相关项目开发

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

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

cobweb-is/laravel-snappy

Composer 安装命令:

composer require cobweb-is/laravel-snappy

包简介

Snappy PDF/Image for Laravel 4

README 文档

README

For Laravel 5, check the 0.2/master branch

This package is a ServiceProvider for Snappy: https://github.com/KnpLabs/snappy.

You need to have wkhtmltopdf/wkhtmltoimage installed. You can download wkhtmltopdf from http://wkhtmltopdf.org/downloads.html See https://github.com/KnpLabs/snappy#wkhtmltopdf-binary-as-composer-dependencies how to do it with composer. Please note that some dependencies (libXrender for example) may not be present on your system and may require manual installation. After installing, verify first if wkhtmltopdf works correctly when invoked from the command line / shell.

The package provides $app['snappy.pdf'] and $app['snappy.image']. You have to set the binary location in the config file. First publish the config file:

php artisan config:publish cobweb-is/laravel-snappy

and then adapt the "binary" line in the published config file (afer publishing should be present in: app/config/packages/cobweb-is/laravel-snappy/config.php).

For example, when loaded with composer, the line should look like:

'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),

In addition to the Snappy classes, it provides a wrapper, similar to https://github.com/barryvdh/laravel-dompdf

Require this package in your composer.json and update composer.

"cobweb-is/laravel-snappy": "0.1.x"

After updating composer, add the ServiceProvider to the providers array in app/config/app.php

'Barryvdh\Snappy\ServiceProvider',

You can optionally use the facade for shorter code. Add this to your facades:

'PDF' => 'Barryvdh\Snappy\Facades\SnappyPdf',
'Image' => 'Barryvdh\Snappy\Facades\SnappyImage',

You can create a new Snappy PDF/Image instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download.

Using the App container:

$snappy = App::make('snappy.pdf');
//To file
$snappy->generateFromHtml('<h1>Bill</h1><p>You owe me money, dude.</p>', '/tmp/bill-123.pdf');
$snappy->generate('http://www.github.com', '/tmp/github.pdf'));
//Or output:
return new Response(
    $snappy->getOutputFromHtml($html),
    200,
    array(
        'Content-Type'          => 'application/pdf',
        'Content-Disposition'   => 'attachment; filename="file.pdf"'
    )
);

Using the wrapper:

$pdf = App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream();

Or use the facade:

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

You can chain the methods:

return PDF::loadFile('http://www.github.com')->stream('github.pdf');

You can change the orientation and paper size

PDF::loadHTML($html)->setPaper('a4')->setOrientation('landscape')->setOption('margin-bottom', 0)->save('myfile.pdf')

If you need the output as a string, you can get the rendered PDF with the output() function, so you can save/output it yourself.

You can publish the config-file to change some settings (default paper etc).

php artisan config:publish cobweb-is/laravel-snappy

See the wkhtmltopdf manual for more information/settings.

License

This Snappy Wrapper for Laravel is open-sourced software licensed under the MIT license

cobweb-is/laravel-snappy 适用场景与选型建议

cobweb-is/laravel-snappy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 165 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「image」 「snappy」 「pdf」 「laravel」 「wkhtmltopdf」 「wkhtmltoimage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cobweb-is/laravel-snappy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cobweb-is/laravel-snappy 我们能提供哪些服务?
定制开发 / 二次开发

基于 cobweb-is/laravel-snappy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 283
  • 开发语言: PHP

其他信息

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