|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.OutOfMemoryException while Creating PDF filesI am using C# with framework 2.0 and creating PDF files on-fly, along with this I am using Windows 2003 Server. I am using Byte[] to take the data input and then save into pdf format on harddrive location. Now after creating few successful pdf files, I am getting "System.OutOfMemoryException". Is this problem coming because of large data is been sent to Byte[] to create PDF file or something else could be the cause. If so, then how to resolve this issue?? Thanks in Advance, Manoj Don't read the entire file into a byte array. Instead, process it in
manageable chunks, reading a smaller chunk of the file at a time. -- Show quoteHTH, Kevin Spencer Chicken Salad Surgeon Microsoft MVP "Aryan" <manoj241***@gmail.com> wrote in message news:1193134132.818741.239850@i38g2000prf.googlegroups.com... > Hi, > > I am using C# with framework 2.0 and creating PDF files on-fly, along > with this I am using Windows 2003 Server. > > I am using Byte[] to take the data input and then save into pdf format > on harddrive location. > > Now after creating few successful pdf files, I am getting > "System.OutOfMemoryException". > > Is this problem coming because of large data is been sent to Byte[] to > create PDF file or something else could be the cause. > > If so, then how to resolve this issue?? > > Thanks in Advance, > > Manoj > Keven, Thanks for prompt reply.
Here is the sample code snippet. I am using SQLReport Server 2005 to get the data. Byte[] results; ReportExecutionService rsExec; results = rsExec.Render(format, deviceInfo, out extension, out encode, out mimeType, out warnings, out streamIDs); SavePDF(results, filename); // calling SavePDF method to save the result array output in PDF form. private bool SavePDF(Byte[] results, string fileName) { try { using (FileStream stream = File.OpenWrite(fileName)) { stream.Write(results, 0, results.Length); stream.Close(); stream.Dispose(); } return true; } catch(Exception ex) { throw; } } Now, 1> If I get large stream from ReportExecutionService then how to split it in chunks and create a pdf file(say pdf has something around 3000 / 5000 pages in it) Thanks in Advance. Manoj |
|||||||||||||||||||||||