我最近使用php 5.5.9和laravel 5.2.0在web应用程序中使用phpjasperxml制作了pdf报告。 我在ireport 5.6.0中做了报告,它运行得很好。 但是当我尝试从Web应用程序显示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.0",
"laracasts/flash": "^3.0",
"fzaninotto/faker": "^1.7"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*",
"barryvdh/laravel-dompdf": "0.6.*",
"phpoffice/phpword": "dev-master",
"laurentbrieu/tcpdf": "dev-master",
"sergio-vilchis/laravel-phpjasperxml": "^1.0",
"jaspersoft/rest-client": "v2.0.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"PhpOffice\\PhpWord\\": "src/PhpWord"
}
},
"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",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
Controller.php这样
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Requests\ReportesRequest;
use Illuminate\Support\Facades\DB;
use PHPJasperXML;
use Response;
class ReportesController extends Controller
{
public function Reporte_planilla_dieta_prof_noDocpdf($tipo)
{
$parametros = explode(' ', $tipo);
$verdescar=$parametros[0];
$mes=$parametros[1];
$anio=$parametros[2];
$server="localhost";
$db="siarcaf";
$user="root";
$pass="";
$version="0.8b";
$pgport=5432;
$pchartfolder="./class/pchart2";
//display errors should be off in the php.ini file
//ini_set('display_errors', 0);
//setting the path to the created jrxml file
$xml =simplexml_load_file("C:/xampp/htdocs/siarcaf/resources/views/Reportes/Reporte_planilla_dieta_prof_noDocpdf.jrxml");
$PHPJasperXML = new PHPJasperXML();
//$PHPJasperXML->debugsql=true;
//dd($mes12);
$PHPJasperXML->arrayParameter=array("mes1"=>"'$mes'");
//dd($sql);
//$PHPJasperXML->sql = $sql;
$PHPJasperXML->xml_dismantle($xml);
$dbdriver="mysql";
$PHPJasperXML->transferDBtoArray($server,$user,$pass,$db,$dbdriver);
//ob_end_clean();
//dd($PHPJasperXML);
if($verdescar==1) //page output method I:standard output D:Download file
{
$PHPJasperXML->outpage("I");
//return Response::make($PHPJasperXML->outpage("I"));
}
if($verdescar==2)
{
$PHPJasperXML->outpage("D");
}
}
}
答案 0 :(得分:0)
PHPJasperXML需要表达式中图像的绝对基本路径。您可以按参数或字段传递表达式。您的图片路径必须是实时var / www / html / SITE_FOLDER / IMAGE_PATH
并且评估类型必须为字符串。