Skip to Content
avatar image
Former Member

How can I print an .rpt file in the Browser using PHP?

Hi,

I need to print the .rpt file in the browser using PHP.

The code that I use is:

<?php

//- Variables - for your RPT and PDF echo "Print Report Test";

$my_report = "C:\\TestFolder\\SubFolder1\\MyWebReport.rpt"; // rpt source file

$my_pdf = "C:\\TestFolder\\SubFolder1\\MyWebReport.pdf"; // RPT export to pdf file

//-Create new COM object-depends on your Crystal Report version

$ObjectFactory= new COM("CrystalReports115.ObjectFactory.1") or die ("Error on load"); // call COM port

$crapp = $ObjectFactory-> CreateObject("CrystalDesignRunTime.Application");

// create an instance for Crystal

$creport = $crapp->OpenReport($my_report, 1); // call rpt report

//export to PDF process

$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf

$creport->ExportOptions->PDFExportAllPages=true; $creport->ExportOptions->DestinationType=1; // export to file

$creport->ExportOptions->FormatType=31; // PDF type

$creport->Export(false); //------ Release the variables ------

$creport = null;

$crapp = null;

$ObjectFactory = null; //------And Now -> Embed the report in the webpage ------

print "MyWebReport.pdf\" width=\"100%\" height=\"100%\">"

?>

The error is:

Print Report TestPrint Report Test Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `CrystalReports115.ObjectFactory.1': Invalid Sintax. ' in C:\inetpub\wwwroot\wms\test_report.php:13 Stack trace: #0 C:\inetpub\wwwroot\wms\test_report.php(13): com->com('CrystalReports1...') #1 {main} thrown in C:\inetpub\wwwroot\wms\test_report.php on line 13

Someone can help me?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 10, 2017 at 11:20 PM

    You are using the 11.5 RDC, no longer supported.

    Try searching first, I'm not sure if PHP will work at all.

    Don

    Add comment
    10|10000 characters needed characters exceeded