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;
}
}
}