save to PDF not working

Stimulsoft Reports.PHP discussion
Post Reply
sachila
Posts: 2
Joined: Tue Jul 25, 2017 8:08 am

save to PDF not working

Post by sachila »

I'm trying to save my report as pdf using Adobe pdf file option. But the stimulsoft.viewer.js gives me this error

Code: Select all

Uncaught TypeError: Cannot read property 'length' of null
    at StiImageCache.addImageInt (stimulsoft.reports.js:244617)
    at StiPdfExportService.storeImageData (stimulsoft.reports.js:226678)
    at StiPdfExportService.exportPdf1 (stimulsoft.reports.js:227214)
    at StiPdfExportService.exportTo (stimulsoft.reports.js:225682)
    at Promise._tryFunction (stimulsoft.reports.js:225688)
    at Promise.callTry (stimulsoft.reports.js:53644)
    at Promise.try (stimulsoft.reports.js:53609)
    at StiPdfExportService.exportToAsync (stimulsoft.reports.js:225687)
    at callback (stimulsoft.viewer.js:11727)
    at StiJsViewer.jsObject.postExport (stimulsoft.viewer.js:11748)
What am I doing wrong? here is my full viewer.php file

Code: Select all

<?php
   header ( "Access-Control-Allow-Origin: * " );
   header ( "Access-Control-Allow-Methods: PUT,POST, GET, DELETE, OPTIONS" );
   header ( "Access-Control-Allow-Headers: origin, x-requested-with, content-type, securityToken" );
   
   require_once 'stimulsoft/helper.php';
   $handlerPath = "handler.php";
   
    
   $reportName = $_GET['name']; 

   $serverDomain = "localhost";
   $serverHost = "Myserve";
   $serverUser = "root";
   $serverPW = "123";

   ?>
<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Stimulsoft Reports.PHP - JS Report Viewer</title>
      <!-- Report Office2013 style -->
      <link href="css/stimulsoft.viewer.office2013.whiteteal.css" rel="stylesheet">
      <!-- Stimusloft Reports.JS -->
      <script src="scripts/stimulsoft.reports.js" type="text/javascript"></script>
      <script src="scripts/stimulsoft.viewer.js" type="text/javascript"></script>
      <?php 
         $options = StiHelper::createOptions();
         $options->handler = $handlerPath;
         $options->timeout = 30;
         StiHelper::initialize($options);
         ?>
   </head>
   <body style="margin:0px !important;">
      <script type="text/javascript">
         var options = new Stimulsoft.Viewer.StiViewerOptions();
         Stimulsoft.Base.StiLicense.loadFromFile("license.key");
         
         console.log(options)
         var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);
         
         // Process SQL data source
         viewer.onBeginProcessData = function (event, callback) {
         	event.connectionString = "Server=<?php echo $serverHost; ?>;Database= <?php echo $serverDomain; ?>;UserId=<?php echo $serverUser; ?>; Pwd=<?php echo $serverPW; ?>";
         	<?php StiHelper::createHandler(); ?>
         }
         
         // Manage export settings on the server side
         // viewer.onBeginExportReport = function (args) {
         // 	<?php StiHelper::createHandler(); ?>
         // 	args.fileName = "MyReportName";
         // 	// console.log(args)
         // }
         
         // Process exported report file on the server side
         // viewer.onEndExportReport = function (event) {
         // 	console.log("working 2")
         // 	//event.preventDefault = true; // Prevent client default event handler (save the exported report as a file)
         // 	<?php StiHelper::createHandler(); ?>
         // }
         
         // Send exported report to Email
         viewer.onEmailReport = function (event) {
         	<?php StiHelper::createHandler(); ?>
         }
         
         // Load and show report
         var report = new Stimulsoft.Report.StiReport();
         var str = "<?php echo $reportName; ?>"; 
         
         report.loadFile("reports/"+str+".mrt");
         viewer.report = report;
         viewer.renderHtml("viewerContent"); 
         
      </script> 
	<div id="htmlContainer"></div>

   </body>
</html>
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: save to PDF not working

Post by HighAley »

Hello.

It seems that there is an issue with getting an image.
Could you send us a sample with all necessary data that will help us to reproduce the issue?

Thank you.
sachila
Posts: 2
Joined: Tue Jul 25, 2017 8:08 am

Re: save to PDF not working

Post by sachila »

HI

Thank you for the response. As you mentioned the problem is with the image alignment. I change the alignments properly and now it's working perfectly.

Thanks
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: save to PDF not working

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you need our help.

Thank you.
Post Reply