PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Thu Apr 02, 2026 7:32 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Oct 16, 2014 11:12 am 
Offline

Joined: Tue Jun 24, 2014 6:34 am
Posts: 3
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 :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 16, 2014 11:29 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3144
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: AhrefsBot, Baidu [Spider], GPT and 732 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group