Hi,
I am trying to creating PDF from Images. But after 3 or 4 images it give me exception that out of memory.
Exact error is.
The CLR has been unable to transition from COM context
Following is code that i am using
foreach (FilePages filepage in fileObject.FilePages)
{
Aspose.Pdf.Page page = FilepdfDocument.Pages.Add();
MemoryStream mystream = new System.IO.MemoryStream(filepage.Data);
Aspose.Pdf.Image Pageimage = new Aspose.Pdf.Image();
Bitmap bitmap = new Bitmap(mystream);
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Right = 0;
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Width = bitmap.Width;
page.PageInfo.Height = bitmap.Height;
Pageimage.ImageStream = mystream;
if (bitmap.Width > page.PageInfo.Height)
{
page.PageInfo.IsLandscape = true;
}
else
{
page.PageInfo.IsLandscape = false;
}
Pageimage.FixWidth = page.PageInfo.Width;
Pageimage.FixHeight = page.PageInfo.Height;
page.Paragraphs.Add(Pageimage);
Pageimage.ImageStream = mystream;
}
FilepdfDocument.Save(PDFMstream);
}