This is neither the fix, nor the workaround. We specifically asked for the stream because in our case we do not work with files and this is a critical requirement. Please reopen the task and fix the issue on streams.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-54709
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Instead of re-opening the ticket, we have generated a new one as shared above. We will address your concerns in this ticket and let you know as soon as this ticket is also resolved. We apologize for the inconvenience caused.
Please use this snippet to avoid ObjectDisposedException:
byte[] pictureBytes = File.ReadAllBytes(PictureFilePath); //this line moved here from inner loop
using (MemoryStream ms = new MemoryStream(pictureBytes)) //this line moved here from inner loop
using (FileStream fs = File.Open(OutputFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
using (StreamWriter sw = new StreamWriter(fs, new UTF8Encoding()))
{
for (int i = 0; i < 2; i++)
{
...
GenerateDataTableRowWithPicture(dataTable, styles, ColumnCount2, 1, ms);
Console.WriteLine(i);
pdf.Save(sw.BaseStream);
}
}