Hi Support,
Can you comment on the attached code which needs to convert any .doc or docx document to a tif file with width : 1728pixels x height 2320 pixels, resolution : 300dpi, Compression CCITT4. This code did work in a previous vesrion of Aspose that I evaluated, I have since purchased a copy but the new version truncates the data in the resultant tiff. Can you advise whats wrong.
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\\Aspose.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;
}
}
}
Thanks Clive