Karthik
Karthik

Reputation: 2399

Print multiple reports in a single PDF file

hi i need some help in pdf generation in crystal reports.The Scenario is ,the user can select multiple values from the grid view for which pdf files are generated on clicking a print button.As of now if the user selects 2 details and click print button 2 pdf files are created .But I need to change the functionality in such a way that the report of records selected by user should be saved in a single pdf file irrespective of the number of records . the code am currently using is

rprt.SetDataSource(rptDataSet); 
rprt.ExportToDisk(ExportFormatType.PortableDocFormat, filePath);

DiskFileDestinationOptions dfdo = ExportOptions.CreateDiskFileDestinationOptions(); 

ExportOptions eo = new ExportOptions();

eo.ExportFormatType = ExportFormatType.PortableDocFormat;
eo.ExportDestinationType = ExportDestinationType.DiskFile; 
dfdo.DiskFileName = filePath;
eo.ExportDestinationOptions = dfdo; 
rprt.Export(eo);

Upvotes: 0

Views: 2366

Answers (1)

Lee Tickett
Lee Tickett

Reputation: 6027

I think you have two options (maybe more):

  • Modify the crystal report slightly by adding a new grouping on your "primary key". Then you can just pass the dataset for all highlighted records and one pdf will be created
  • Export each pdf separately then "stuff" them together

Systems I use take the first approach- i think it's more efficient.

EDIT As requested- i've attached a sample invoice report which is used for printing batches of invoices. Group 2 is on {LT_INVOICE.TRANSACTIONID} which will be unique for each invoice.

enter image description here

Upvotes: 1

Related Questions