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

Free Support Forum - aspose.com

Creating multi page Tiff from several single page Tiff files

Sample code would be most appreciated.



Hi Parkoos,

Thank you for contacting Aspose support.

Please refer to this technical article for concatenating different Tiff images into an existing Tiff image. If you intend to create a new image by adding the frames of several Tiff images then please check the following piece for code.


List<string> files = new List<string>(new string[] { myDir + “merged.tif”, myDir + “sample1.tiff” });
//Create and instance of TiffOptions and set its various properties
TiffOptions createOptions = new TiffOptions();
FileStream fileStream = new FileStream(myDir + “Concat.tif”, FileMode.Create);
createOptions.Source = new StreamSource(fileStream);
createOptions.BitsPerSample = new ushort[] { 8, 8, 8 };
createOptions.Photometric = TiffPhotometrics.Rgb;
createOptions.Compression = TiffCompressions.Lzw;

//Create a new image by passing the TiffOptions and size of first frame
//we will remove the first frame at the end, cause it will be empty
using (var output = (TiffImage)Image.Create(createOptions, 100, 100))
foreach (var file in files)
//Create an instance of TiffImage and load the source image
using (TiffImage input = (TiffImage)Aspose.Imaging.Image.Load(file))
foreach (var frame in input.Frames)
// Add copied frame to destination image
// save the image with changes

//Check if output Tiff have more than 1 frames
if (output.Frames.Length > 1)
//Set second frame to be active
output.ActiveFrame = output.Frames[1];
//Remove first empty frame from output image
// save the image with changes

Please feel free to write back in case you need our further assistance.

Thanks Babar,

I used the sample code you provided, but am getting an exception

Object Reference not set to an instance of an object

I am getting this on output.save after adding a frame.

I am attaching a zip file with a class I created to handle this as well as the two tiff files I am using for testing. I also have a stacktrace from the windows form program I am using as a test bed

Note that I am using the width and height of the incoming file in tiffOptions.


Hi Parkoos,

Thank you for providing test material.

We have evaluated your presented scenario on our end while using the latest version of Aspose.Imaging for .NET 2.3.1. Unfortunately, we are unable to observe any exception with your provided code (clsMultiPageTiff class). Please note, we have tested this scenario in evaluation as well as licensed mode on Windows 7 Home Premium 64-bit with both of your files while flipping bHandleColor to both values. The usage scenario is as follow with out making any changes to your core class,


clsMultiPageTiff obj = new clsMultiPageTiff();
obj.AddIt(myDir + “INVOICE1.tif”, myDir + “output.tif”, true);

Please download and use the latest assemblies (link shared above) in case you are using any older version of the API. If you are already using the latest version or the problem persists, please provide more details of your environment, such as Operating System version, Operating System Architecture(32-bit/64-bit), Target Framework etc. Upon receiving the requested information, we will simulate your environment on our end to re-evaluate the issue.


I had the version that I had downloaded last year when working with another client.

The latest version works fine

I apologize for wasting your time.



I had another issue while running the code in my real program and not the test bed - hope you can help with this.

Access is denied to my file which is in my local documents and settings and not in the BIN folder of the executable while loading image.

"Access to the path 'C:\\Documents and Settings\\parkoos.DVLX\\Local Settings\\Temp\\2\\tmp16.tif' is denied."

Aspose.Imaging.FileFormats.Tiff.TiffImage imageIn = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Load(sInFileName);

sInFileName is the file in the access denied exception.

I tried to figure out security permissions for the dot net assembly but did not get far.



Hi Parkoos,

Thank you for the confirmation on your previously posted problem.

Regarding “Access to path denied” exception, the problem is purely related to access permission on the file/folder that you are trying to read. If you are building an ASP application, you need to find out the application pool for the website what is the identity it is running under (by default this is Application Pool Identity) and grant that the correct permissions. Otherwise, check the permissions on the file and try running the Visual Studio in Administrator mode.


This is not an ASP application

Permissions on the file are fine. In fact I even set System.Security.Permissions.FileIOPermission to Read. But no go.

Interestingly, other Aspose products such as Aspose.Pdf and Aspose.Word have no problems reading files from the same location.

Could you please look into this some more?


Hi Parkoos,

Thank you for writing back.

Sure, we will look into this scenario further. In the meanwhile, please perform a few tests on your end, and provide the results here so could analyze the problem cause.

  1. Please start the Visual Studio in Administrative Mode by right clicking the Visual Studio icon/link and select “Run as Administrator”. Load your application and see if you still can reproduce the said exception.
  2. Please place your desired file somewhere other than “My Documents” folder and re-run your application to see the results. You may place the file in any temp directory on any of the root paths such as C:\temp or D:\temp.

Hi Babar,

None of the recommendations above worked.

My code is a class library with COM exposed, and it is called by another program running from a shared file server location.

Anyway, I have resolved the issue. I created a FileStream from the file I was trying to load, and used the stream input instead of the file name.

This works.

Thanks for all your help.


Hi Parkoos,

Good to know that you are up and running again, and thanking for sharing your solution with us. Please feel free to write back in case you need our further assistance with Aspose.Imaging APIs.