I am currently evaluating the Aspose APIs for the purpose of converting documents from one format to another, including TIFF -> PDF and back. I originally ran into the issue of a multi-page TIFF not converting to a multi-page PDF using the standard conversion code, and found alternate examples of code that pull out the frames of a TIFF and manually build the PDF from those. I have been trying to implement those strategies using version 19.10.0 of the .NET imaging library.
However, I’m running into an issue just saving the image frame to a stream so that it can then be added to the PDF. Ultimately, no matter what I do, I keep getting the error, “TiffImageException : Color map entries must contain 2**(bits per sample) values.” I have found no examples that sets the ColorMap property of the TiffOptions when saving an image, so I have no idea what to do here. Below is a bare-bones example that demonstrates the issue I am having. This example simply loads a TIFF image from one stream and tries to write it back to another.
using (var image = (TiffImage)Image.Load(sourceStream))
image.Save(targetStream, new TiffOptions(TiffExpectedFormat.TiffNoCompressionRgb));
What is the proper way to set the ColorMap property of TiffOptions so that it can be saved? Or is there a better way to save off a particular frame of an image that I can then add it to an Aspose.Pdf.Document?