Other Languages - Page correction while exporting to PDF and Word in Crystal Report

Asked By Ramachandran on 18-Oct-11 06:04 AM
In My Crystal Report file having Three Pages 1, 2 and 3 but while exporting to Word and PDF it is showing as 6 Pages with 2nd , 4th and 6th Page as a Blank Page. How to solve this issue. either i want to change in  Crystal Report Design file.
Jitendra Faye replied to Ramachandran on 18-Oct-11 06:08 AM
Try this code to export -

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using System.IO;

protected void ddlExportTypes_SelectedIndexChanged(object sender, EventArgs e)




//And here's the ExportReport function

private void ExportReport()


//declare a memorystream object that will hold out output

MemoryStream oStream;

//here's the instance of a valid report, one which we have already Load(ed)

crReport= new ReportDocument();

/**remember that a valid crystal report has to be loaded before you run this code**/

//clear the response and set Buffer to true


Response.Buffer = true;



case "1":

// ...Rich Text (RTF)

oStream = (MemoryStream)crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.RichText);

Response.ContentType = "application/rtf";


case "2":

// ...Portable Document (PDF)

oStream = (MemoryStream)crReport.ExportToStream(ExportFormatType.PortableDocFormat);

Response.ContentType = "application/pdf";

//in case you want to export it as an attachment use the line below


crReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Your Exported File Name");

* */


case "3":

// ...MS Word (DOC)

oStream = (MemoryStream)crReport.ExportToStream(ExportFormatType.WordForWindows);

Response.ContentType = "application/doc";


case "4":

// ...MS Excel (XLS)

oStream = (MemoryStream)crReport.ExportToStream(ExportFormatType.Excel);

Response.ContentType = "application/vnd.ms-excel";



//...Portable Document (PDF)

oStream = (MemoryStream)crReport.ExportToStream(ExportFormatType.PortableDocFormat);

Response.ContentType = "application/pdf";





//write report to the Response stream




catch (Exception ex)


labelErrors.Text = "ERROR: " + Server.HtmlEncode(ex.Message.ToString());




//clear stream






Hope this will help you.
Riley K replied to Ramachandran on 18-Oct-11 06:15 AM

There is no way to remove the blank pages other than to determine why they are occurring and fix the problem.

A blank last page is normally caused by having NEW PAGE AFTER selected for a sectioni like the DETAILS or a GROUP FOOTER

CR 8 instructions.
Open the report
Select the details section
If NEW PAGE AFTER is checked , uncheck it and click the FORMULA BUTTON to the right
Enter the formula
Not OnLastRecord

If there are groups check each group footer (it will probably be the Group #1 footer)
If NEW PAGE AFTER is checked , uncheck it and click the FORMULA BUTTON to the right
Enter the formula
Not OnLastRecord

If the balnk pages are through out the report you may have NEW PAGE AFTER
or NEW PAGE BEFORE selected so both are producing a pnew page.
For instance if you hae NEW PAGE AFTER  on the group footer and NEW PAGE BEFORE on the group header.

Ramachandran replied to Riley K on 18-Oct-11 06:31 AM
either i want to use any formula or Operator for this No OnLastRecord. where to type this formula in Formula Section.