Closed reisfira closed 5 years ago
Update, I tried the following:
$PHPJasperXML = new PHPJasperXML('en', 'TCPDF');
$PHPJasperXML->arrayParameter = [];
$PHPJasperXML->load_xml_file($input);
$PHPJasperXML->transferDBtoArray(env('DB_HOST'), env('DB_USERNAME'),env('DB_PASSWORD'),env('DB_DATABASE'), 'mysql');
$PHPJasperXML->outpage('I'); // the error happens here btw
So I tried to include, everything as in the readme, still produce the same error... and when I change the driver from mysql to PDO (because I'm using csv), it says:
Failed to get DB handle: could not find driver
Another update, I tried the example on readme, with some modification:
$PHPJasperXML = new PHPJasperXML();
// $PHPJasperXML->debugsql=true;
$PHPJasperXML->arrayParameter=array("parameter1"=>1);
$PHPJasperXML->load_xml_file(base_path()."/vendor/simitgroup/phpjasperxml/sample/sample1.jrxml");
$PHPJasperXML->transferDBtoArray('127.0.0.1','root','','database_name');
$PHPJasperXML->outpage("I"); //page output method I:standard output D:Download file
I get an error:
TCPDF ERROR: [Image] Unable to get image: ./simitlogo.png
Does this mean that I need to put the PHPJasperXML in the Controller folder? (I'm using Laravel btw)
Right now, this is how I use it:
include_once base_path().'/vendor/simitgroup/phpjasperxml/version/1.1/PHPJasperXML.inc.php';
use PHPJasperXML;
class InvoiceController extends Controller
{
public function testReport() {
$PHPJasperXML = new PHPJasperXML();
// $PHPJasperXML->debugsql=true;
$PHPJasperXML->arrayParameter=array("parameter1"=>1);
$PHPJasperXML->load_xml_file(base_path()."/vendor/simitgroup/phpjasperxml/sample/sample1.jrxml");
$PHPJasperXML->transferDBtoArray('127.0.0.1','root','','database_name');
$PHPJasperXML->outpage("I"); //page output method I:standard output D:Download file
$headers = [ 'Content-Type' => 'application/pdf' ];
return response()->file($output.'/invoice.pdf', $headers);
}
}
Maybe I'm doing it wrong?
TCPDF ERROR: [Image] Unable to get image: ./simitlogo.png
Regarding the error, I decided to handle image by absolute path and pass the path by parameter (seems URL doesn't work). That worked.
However, using CSV instead of MySQL is still unresolved for me.
$input = config('custom.input').'invoice/invoice.jrxml';
$output = config('custom.output');
// $sample_xml = base_path()."/vendor/simitgroup/phpjasperxml/sample/sample1.jrxml";
$PHPJasperXML = new PHPJasperXML("en","TCPDF");
$PHPJasperXML->arrayParameter =array();
$PHPJasperXML->load_xml_file($input);
$PHPJasperXML->transferDBtoArray('127.0.0.1','root','','database_name');
$PHPJasperXML->arraysqltable=$data;
$PHPJasperXML->m=count($data);
$PHPJasperXML->outpage('I');
This works now, I guess, just pass an array to arraysqltable did it. Regarding the Class SimpleDateFormat not found error, I simply parse it from php first then pass as string in $data. Closing it now
Great to see you finally solve the problem
Hi again, so I tried a minimal setup like so. I'm using CSV btw:
This looks like a Java error, so I don't really know where to go with this...
Is this because my $PHPJasperXML don't have
$PHPJasperXML->transferDBtoArray()
or$PHPJasperXML->arrayParameter
?