| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Out of Memory Exception in converting larger files https://forum.pdfsharp.net/viewtopic.php?f=2&t=2956 |
Page 1 of 1 |
| Author: | hsahay [ Thu Oct 16, 2014 11:12 am ] |
| Post subject: | Out of Memory Exception in converting larger files |
I am using C# to take an Excel file as input and convert it into PDF. There are no images, just data in the form of tables. Some of the Excel files are very big in size (more than 200,000 rows). Whenever one of these files is converted, the program gives OutOfMemoryException. I tried creating multiple PDFs containing less number of rows using more than 1 PdfDocumentRenderer but that's also not working. I am using the following code for the conversions: Code: PdfDocumentRenderer _pdfRendererDoc1 = new PdfDocumentRenderer(true); Document _doc1 = new Document(); Style _styleDoc1 = _object.SetStyle(_doc1); PdfDocument pdfDoc1 = new PdfDocument(); Section _sectionDoc1 = _object.SetSection(_doc1); Table _tableDoc1 = _object.AddTables(_sectionDoc1); Row _rowDoc1; Cell _cellDoc1; _object.AddColumns(_tableDoc1, colWidth); for (int row = 1; row <= end.Row; row++) { _rowDoc1 = _object.AddRows(_tableDoc1); int col = 1, pdfCol = 0; while (pdfCol < numColumns) { _cellDoc1 = _rowDoc1.Cells[pdfCol]; pdfCol ++; col++; } } _pdfRendererDoc1.Document = _doc1; // Render output file // _pdfRendererDoc1.RenderDocument(); // Save output file // _pdfRendererDoc1.Save(outputFileLocation + outputFileName); Can someone suggest a way out? Can I close a Renderer manually so that the memory is cleared? Thanks in advance |
|
| Author: | Thomas Hoevel [ Thu Oct 16, 2014 11:29 am ] |
| Post subject: | Re: Out of Memory Exception in converting larger files |
General notes about OutOfMemoryException can be found here (3rd post): viewtopic.php?p=8564#p8564 Maybe create a new AppDomain for each renderer to clear the memory completely. First you should try 64 bit mode. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|