Skip to Content
Sep 05, 2013 at 06:59 PM

ExportToDisk - PDF creates corrupt PDF


I have this issue with ExportToDisk function with a large report. When I open and preview the report in Visual Studio, I am able to export the document just fine. Doing this through code, it fails causing the PDF to be corrupt.

The document I am having issues with is 261 pages. Each page contains an image stored in an xml data file. This is working with smaller page documents. For example, it is working with 135 images/pages.

private void ProcessFormRPT(string docPath, string xmlDataFile)


System.Data.DataSet ds = new System.Data.DataSet();

ds.ReadXml(xmlDataFile, System.Data.XmlReadMode.ReadSchema);

CrystalDecisions.Shared.ConnectionInfo cInfo = GetXMLLogin(xmlDataFile);

ReportDocument doc = new ReportDocument();



foreach (ReportDocument subreport in doc.Subreports)


setConnectioninfo(subreport, cInfo, ds, xmlDataFile);



setConnectioninfo(doc, cInfo, ds, xmlDataFile);


doc.SaveAs(docPath, false);

doc.ExportToDisk(ExportFormatType.PortableDocFormat, ResultFile);


} // ProcessFormRPT

I have tried using ExportToStream as well, with no luck.

I tried setting the registry "PrintJobLimit" to -1 without any success.

Is there a limit to the number of pages, or memory constraints? Is there a registry setting I need to adjust?

I am using Visual Studio 2010

Note: I can post the procedures setConnectioninfo and GetXMLLogin needed.