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

Free Support Forum - aspose.com

Getting out of memory on current version 11 saving to tif

Hi Support,

I am using this sample code to read a word document and save it to tif. It works for simple documents but fails on our test document. Can you advise what the problem is please.

I am running the test code on a windows 2008 R2 box with 16GB memory of which 13GB is free.

Code and test document attached.

Thanks

Clive

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace TestAspose

{

class Program

{

static void Main(string[] args)

{

string infile = "c:\\junk\\installation4.docx";

string outfile = "c:\\junk\\Aspose.tiff";

bool result = Word(infile, outfile);

if (result == false)

Console.WriteLine("Conversion did not work");

else

Console.WriteLine("Conversion complete");

}

public static bool Word(string inputfullpath, string outputfullpath)

{

//string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

//string dataDir = Path.GetFullPath(Path.Combine(inputdirectory, @"..\..\Data\"));

//Open the document.

bool ret = true;

try

{

Aspose.Words.Document doc = new Aspose.Words.Document(inputfullpath);

Aspose.Words.Saving.ImageSaveOptions imgOptions = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Tiff);

imgOptions.Resolution = 300;

imgOptions.TiffCompression = Aspose.Words.Saving.TiffCompression.Ccitt4;

//Convert resolution between the default and the specified DPI

//There is extra code needed because the resolution is not the default (96). This code will produce an image with the dimensions almost exactly as 1728x2320.

doc.Sections[0].PageSetup.PageHeight = Aspose.Words.ConvertUtil.PixelToPoint(Aspose.Words.ConvertUtil.PixelToNewDpi(2320, imgOptions.Resolution, 96));

doc.Sections[0].PageSetup.PageWidth = Aspose.Words.ConvertUtil.PixelToPoint(Aspose.Words.ConvertUtil.PixelToNewDpi(1728, imgOptions.Resolution, 96));

Aspose.Words.Saving.SaveOutputParameters p = doc.Save(outputfullpath, imgOptions);

}

catch (Exception)

{

ret = false;

}

return ret;

}

}

}

Hi,

Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. 11.0.0, I managed to reproduce this exception on my side. For the sake of correction, I have logged this issue in our bug tracking system. Your request has also been linked to the appropriate issue and you will be notified as soon as it is resolved. Sorry for inconvenience.

Moreover, I found that for some reasons Aspose.Words is not able to render the following image in your document (page 2) to TIFF format:



Also, as a temporary work around,I would suggest you use the following code snippet:

Document docx = new Document(@"c:\test\Installation4.docx");

MemoryStream stream = new MemoryStream();
docx.Save(stream, SaveFormat.Doc);

Document doc = new Document(stream);
doc.Save(@"c:\test\out.tiff");

I hope, this will help.

Best Regards,