I’m getting a GDI+ error using the code below with the attached document. Stack following.
The document is intended to stress memory usage. It appears to me that Aspose is failing to save my LZW TIFF. Looking at the stack, it’s clear you’re writing pages to the output TIFF using .NET GDI using a stream as output. What I’m not sure of is if it’s a memory stream or a disk stream and how/if I can control that. If it’s a memory stream, I’m worried I’m running out of memory and would prefer to output directly to disk as that is my final medium.
I haven’t found an incarnation of ConversionHandler.Convert that takes a destination stream. Can it be set in the save options and I’m just not seeing it?
Code:
` var config = new ConversionConfig();
var conversionHandler = new ConversionHandler(config);
var imageSaveOptions = new ImageSaveOptions
{
ConvertFileType = ImageSaveOptions.ImageFileType.Tiff,
Grayscale = true,
TiffOptions =
{
Compression = TiffOptions.TiffCompression.Lzw
},
HorizontalResolution = 203,
VerticalResolution = 192,
};
using (var source = File.OpenRead(parameters.Source.File))
{
using (var destination = File.OpenWrite(parameters.Target.File))
{
using (var result = conversionHandler.Convert(source, imageSaveOptions))
{
result.Save(destination);
}
}
}`
Stack:
at System.Drawing.Image.SaveAdd(Image image, EncoderParameters encoderParams) at .( ) at .(Int32 , Stream ) at . ( ) at . ( ) at Aspose.Words.Document.( , SaveOptions ) at Aspose.Words.Document.(Stream , String , SaveOptions ) at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions) at . (Stream ) at . (Stream , SaveOptions ) at .( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at . ( , SaveOptions ) at GroupDocs.Conversion.Handler.ConversionHandler.( , SaveOptions ) at GroupDocs.Conversion.Handler.ConversionHandler.Convert(Stream fileStream, SaveOptions saveOptions)
Source document:
LargeDocx.zip (366.8 KB)
Thanks
-Jonathan