We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Direct-To-File mode stops writing to stream

Hi, I'll apologize for the lack of an explicit example for this problem up front. I have not been able to narrow down what exactly is causing this behavior.

I'm creating fairly large pdf files (10-15Mb on average). I load up a series of data objects write each one to the pdf as a table (15 rows avg) and save it to a memory stream. This works well for smaller files, but not with larger ones, so I'm attempting to refactor to use Direct-To-File mode.

What I've noticed is this:

* My pdf on the disk grows and grows, then it stops growing and the memory starts growing and it will never write to the file stream again.

* I've also noticed that this seems to be directly related to specific data objects that I am attempting to write. If I exclude those specific objects the pdf will write to disk properly. These problemed objects are no larger than any of the other objects that write properly.

My problem is that I am unable to determine what it is about the data in those objects that would cause this behavior. The files I'm testing with inevitably max out the memory available in a 32-bit process, so I'm not sure if it would ever finish or not.

Could you tell me:

* How and when does the Pdf determine it needs to flush data to the file? Calling "Section.AddParagraph" doesn't seem to flush the stream every time you call it.

* Is there anything outside of "new Pdf(Stream)" and "Section.AddParagraph" I need to be aware of when using Direct-To-File mode?

* Is there any explicit documentation or articles that would describe this mode in it's entirety and how to use it?

I've spent a fair amount of time trying to narrow down what is unique about my data that would cause this problem, and have been unsuccessful.

I appreciate any help you can give me. Thanks!


I've also just noticed that if I write just the table header for all of my "good" items, and write out the entire table for the "bad" items, the "bad" items print perfectly.

This makes me wonder if it's not so much the data that I'm writing but the calculation used to determine when to render objects to the file stream. If it's useful, I create my pdf like this:

* Create new pdf object

* Create new section (the only section in the document

* Loop

* Create Table

* Add Rows / Cells / Data

* Section.AddParagraph(Table)

* Close the pdf

Hi Tony,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the details.

You may check the details regarding Direct-to-file mode using the following link:


As mentioned in the documentation, in direct to file working mode, when a new Paragraph is added to a PDF document, Aspose.Pdf for .NET writes it directly to the Pdf file and frees the memory used by the Paragraph. Please check the steps mentioned in the document and if you are following the same steps and still facing the problem, please create a sample application to help us generate the issue at our end. We will check it and get back to you soon.

Thank You & Best Regards,

Thank you for the quick response. My code is essentially doing the same thing as the documentation you provided. Replace "AddParagragh(Text)" with "AddParagraph(Table)" and that's my code. There are, of course, some fonts in bold or aligned differently etc.

I have been unsuccessful in recreating this scenario in a simple example. I will continue to try however. The scenario is repeatable in my production code, but since i can't pinpoint what causes the issue, I'm having to copy / finagle a fair amount of code & sensitive data into a test project for you to be able to repeat it.

I'll get it to you as soon as I can get it to replicate the problem. Thanks!