I had a similar problem. On my report there are some texts and images. I have read that Crystal Report first converts the JPG, PNG, etc images to BMPs then it shows the report. And converting other image type to BMP consumes much memory. First I tried to convert JPG images to BMP images in my database but then my database became bigger and bigger. Finally I found the solution (thanks to this answer).
Instead of trying to export all pages to PDF file I splitted files, zipped them and download the zip file:
Dim exportOpts As ExportOptions = New ExportOptions()
Dim pdfRtfWordOpts As PdfRtfWordFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions()
Dim destinationOpts As DiskFileDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions()
Dim intPageCount As Integer = crReportDocument.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)
Dim pagecount As Integer
pagecount = Int(intPageCount / 100) + 1
Dim sonsayfa As Integer
Dim ilksayfa As Integer
Dim Anadosyaadi As String
Dim foldername As String
Dim foldernameMap As String
Anadosyaadi = Now.ToString("yyyy-MM-dd-hh-mm-ss")
foldername = "C:\inetpub\wwwroot\" + Anadosyaadi
foldernameMap = "./" + Anadosyaadi
If Not Directory.Exists(foldername) Then
Directory.CreateDirectory(foldername)
End If
For li_count As Integer = 1 To pagecount
ilksayfa = (li_count - 1) * 100 + 1
pdfRtfWordOpts.FirstPageNumber = ilksayfa
sonsayfa = li_count * 100
If sonsayfa > intPageCount Then sonsayfa = intPageCount
pdfRtfWordOpts.LastPageNumber = sonsayfa
pdfRtfWordOpts.UsePageRange = True
exportOpts.ExportFormatOptions = pdfRtfWordOpts
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
destinationOpts.DiskFileName = foldername + "\" + li_count.ToString + ".pdf"
exportOpts.ExportDestinationOptions = destinationOpts
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
crReportDocument.Export(exportOpts)
Next
Using zip As ZipFile = New ZipFile
zip.AddDirectory(foldername)
zip.Save(foldername + "\" + Anadosyaadi + ".zip")
End Using
Response.Redirect(foldernameMap + "/" + Anadosyaadi + ".zip")
PS1: I used Ionic.Zip to zip the files. You should add
Imports Ionic.Zip
on top of your source.
PS2: When I restart the server, without doing anything else, I can get 500 pages of PDF from page number 1 to 500. At this time, I think, Crystal Reports uses some memory. Then if I want to get the second 500 pages (I mean from page number 501 to 1000), I see memory full error. Then I can get 300 pages (from 501 to 800). Then another memory full problem and I can get from 801 to 900, etc. That's why I preferred to split 100 pages. Maybe you can change it to another number.