Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need to send attachment that is needed to convert Jasper report url to pdf and attach that pdf to mail.

What I have tried:

While I use this mentioned code, convert jasper report url to pdf, it does not read the content, it only generates pdf that pdf contains instead of content...
Search Access Denied. You do not have permission to view this page. Please contact your system administrator or log in as a user with permission. About TIBCO JasperReports Server Copyright © 2005-2021 TIBCO Software Inc.

PHP
require_once(APPPATH."third_party/dompdf/dompdf_config.inc.php");
$dompdf = new Dompdf();
$jasperReportUrl = 'jasper report url contains username and password and ip.....';
 
// Initialize cURL session
$ch = curl_init($jasperReportUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$reportContent = curl_exec($ch);

if ($reportContent === false) {
    echo 'cURL Error: ' . curl_error($ch);
} else {
    $dompdf->load_html($reportContent);
    $dompdf->set_paper('A4', 'portrait');
    ini_set('memory_limit', '256M');
    set_time_limit(300);
    $dompdf->render();
    $pdfFilePath = 'file path';
    file_put_contents($pdfFilePath, $dompdf->output());
   
    $this->email->attach($pdfFilePath);
}

   curl_close($ch);
Posted
Updated 2-Oct-23 4:56am
v4
Comments
Richard MacCutchan 26-Sep-23 5:52am    
"coding is not working for me."
Sorry, but no one here can guess what that is supposed to mean. Please use the Improve question link above, and add complete details of what is not working.
[no name] 26-Sep-23 14:03pm    
All this should be running on the server ... Getting "page access violations" makes no sense.

1 solution

Try mPDF instead mPDF – mPDF Manual[^]. I am using it in similar use case and works flawlesly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900