我有一个带有Ubuntu 14.04,Apache2,php 7.2,Laravel 5.2的EC2实例。
当用户点击此功能时:
public function show(Request $request, $id)
{
$type = $id; // 'pdf' / 'xls'
$data = $this->getConversionsByDate();
$data = $this->parseData($data['conversions'],$type);
return Excel::create('project_conversions_data_'.Carbon::now()->toDateTimeString(), function($excel) use ($data) {
$excel->sheet('mySheet', function($sheet) use ($data){
$sheet->fromArray($data);
});
})->download($type);
}
当type ='xls'->时,它工作正常。 但是,当type ='pdf'时,我遇到了这个新错误:
PHPExcel_Writer_Exception:无法在/var/www/html/project/releases/20190108072816/vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/PDF/DomPDF.php:8
中加载PDF呈现库
这是我的composer.json文件:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.*",
"jenssegers/agent": "2.3.*",
"doctrine/dbal": "v2.5.5",
"guzzlehttp/guzzle": "~6.0",
"laravel/cashier": "~6.0",
"spatie/laravel-backup":"^3.0.0",
"maatwebsite/excel": "~2.1.0",
"rap2hpoutre/laravel-log-viewer":"0.8.0",
"arcanedev/log-viewer": "4.2.*",
"tymon/jwt-auth": "0.5.*",
"aws/aws-sdk-php-laravel": "3.1.0",
"league/flysystem-aws-s3-v3": "~1.0.0",
"maknz/slack-laravel": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helpers.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate"
]
},
"config": {
"preferred-install": "dist"
}
}
请帮助!!!
答案 0 :(得分:0)
这是我快速浏览文档后发现的。 请检查package.json
中是否包含以下软件包导出为PDF 要将文件导出为pdf,您必须在其中包含“ dompdf / dompdf”:“〜0.6.1”,“ mpdf / mpdf”:“〜6.1”或“ tecnick.com/tcpdf”:“~6.0.0”您的composer.json并相应地更改export.pdf.driver配置设置。
答案 1 :(得分:0)
这是我的解决方案:
composer require tecnickcom/tcpdf
转到config / excel.php并进行以下更改:
'driver' => 'DomPDF',
到
'driver' => 'tcPDF',
在同一文件中,更改以下内容:
'tcPDF' => array(
'path' => base_path('vendor/tecnick.com/tcpdf/')
),
收件人:
'tcPDF' => array(
'path' => base_path('vendor/tecnickcom/tcpdf/')
),
它有效:)