Please enable JavaScript to view this site.

Navigation: Developer Information > Programming Environments

Crystal Reports

Scroll Prev Top Next More

The following Visual C example shows how to print a document to Win2PDF using Crystal Reports.

 

void CPrinting::PrintPDF(LPTSTR sPrintType, int iPrintMethod)

{

 _TCHAR sFileName[PE_FILE_PATH_LEN] = "";

 short hJob = 0;

 PEPrintOptions PrintOptions;

 

 PEOpenEngine();

 hJob = PEOpenPrintJob("d:\\pics32\\pics32\\live\\quote.rpt");

 

 PrintOptions.StructSize   = PE_SIZEOF_PRINT_OPTIONS;

 PrintOptions.startPageN   = 1;

 PrintOptions.stopPageN   = -1;

 PrintOptions.nReportCopies = 1;

 PrintOptions.collation   = PE_COLLATED;

 

 _tcscpy(sFileName, "D:\\temp\\test.pdf"); // Here is the PDF file name

 _tcscpy(PrintOptions.outputFileName, sFileName);

 

 PESetPrintOptions(hJob, &PrintOptions);

 PEOutputToPrinter(hJob, 1);

 PEStartPrintJob(hJob, TRUE);

 PECloseEngine();

}

 

The same example using Visual Basic follows.

 

Public Function printAPIReport(RptName As String, rptPath As String, outPath As String) As Boolean

 Dim PrintOptions As PEPrintOptions

 Dim hjob As Integer

 

 PEOpenEngine()

 hjob = PEOpenPrintJob(rptPath & RptName)

 

 PrintOptions.StructSize = PE_SIZEOF_PRINT_OPTIONS

 PrintOptions.StartPageN = 1

 PrintOptions.stopPageN = -1

 PrintOptions.nReportCopies = 1

 PrintOptions.collation = PE_COLLATED

 PrintOptions.outputFileName = "c:\\Temp\\TEST.PDF" & Chr(0)

   

 PESetPrintOptions(hjob, PrintOptions)

 

 PEOutputToPrinter(hjob, 1)

 

 PEStartPrintJob(hjob, True)

 

 PECloseEngine

End Function