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

Free Support Forum - aspose.com

Image failed to export when converting above 150 pages TIF to PDF

Hi,

I am using Aspose.Imaging v21.9.0.0

Try to convert a 150 pages and above TIF to PDF and it always failed with “Image failed to export” error and “{duplicate}” inner exception message.

Sample code below. Had to use cache to circumvent the out of memory problem.

Aspose.Imaging.Cache.CacheFolder = AppDomain.CurrentDomain.BaseDirectory;
			Aspose.Imaging.Cache.CacheType = 
Aspose.Imaging.CacheType.CacheOnDiskOnly;
long l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
long l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;

MemoryStream ms = new MemoryStream();
	
using (Aspose.Imaging.Image img = Aspose.Imaging.Image.Load(streamTIF) )
{
	TiffImage tiffImg = (TiffImage)img;
	PdfOptions pdfOptions = new PdfOptions()
	{
	ResolutionSettings = new Aspose.Imaging.ResolutionSetting(tiffImg.HorizontalResolution, tiffImg.VerticalResolution),
	//MultiPageOptions = new MultiPageOptions(new Aspose.Imaging.IntRange(0, tiffImg.Frames.Count())),

	};
	//img.Save(AppDomain.CurrentDomain.BaseDirectory + "150.pdf", pdfOptions);
	img.Save(ms, pdfOptions);

	long diskBytes = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
	long memoryBytes = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;
}


			l1 = Aspose.Imaging.Cache.AllocatedDiskBytesCount;
			l2 = Aspose.Imaging.Cache.AllocatedMemoryBytesCount;

			return ms;

151.zip (1.9 MB)

@praetorion

It’s a fairly large image that you are dealing with. Please try using sample code given over following documentation article to load image in batch mode and render that.

Hi,

Unfortunately, the process does not support PDF.

Pdf image exporter does not support batch export mode. Please make sure that PageExportingAction property of the exported image has null value.

@praetorion
We’re able to export your tiff to pdf using following simplified version of your code :

        string fileName = Path.Combine(TestDirectory, "151.tif");
        using (var img = (RasterImage)Aspose.Imaging.Image.Load(fileName))
        {
            PdfOptions pdfOptions = new PdfOptions()
            {
                ResolutionSettings = new Aspose.Imaging.ResolutionSetting(img.HorizontalResolution, img.VerticalResolution),
                // MultiPageOptions = new MultiPageOptions(new Aspose.Imaging.IntRange(0, tiffImg.Frames.Count())),
            };

            img.Save(fileName+".pdf", pdfOptions);
        } 

The resulting pdf file is here. Aspose.Imaging for .NET5 v21.10 x64 was used. Please clarify your configuration and provide the sample application, if the issue still exists.

Hi,

Does it make any difference if I am using x86. Btw I am on Aspose.Imaging .NET4.8 v21.9.0.0

@praetorion
Thank you for clarifications - we’re able to reproduce the issue on x86 platform. We’ve created the issue IMAGINGNET-4920 to work on it within further product releases and linked it to the current thread enabling notifications. Feel free to consider use of x64 platform just now.