Hi Team,
I’m trying to convert a colour PDF to TIFF image using Aspose.PDF. Here’s my current working code:
using (MemoryStream ms = new MemoryStream())
{
properties.GetDocumentStream(doc).CopyTo(ms);
//open document
Aspose.Pdf.Document newDoc = new Aspose.Pdf.Document(ms);
//create Resolution object
Resolution resolution = new Resolution(300);
//create TiffSettings object
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Compression = CompressionType.None;
tiffSettings.Depth = ColorDepth.Default;
tiffSettings.SkipBlankPages = false;
tiffSettings.Shape = ShapeType.Portrait;
//create TIFF device
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
//convert a particular page and save the image to stream
tiffDevice.Process(newDoc, outputFolderPath.TrimEnd('\\') + "\\" + doc.DisplayName + ".tiff");
newDoc.Save();
}
The output of this will always be a colour TIFF image, my questions is that is there any chance we can generate a Grayscale or Black and White TIFF image from a colour PDF using Aspose.PDF TiffSettings?
I noticed Aspose.Words.Saving has ImageSaveOptions which I can use to set ImageColorMode to be either None, Grayscale or BlackAndWhite:
namespace Aspose.Words.Saving
{
//
// Summary:
// Specifies the color mode for the generated images of document pages.
public enum ImageColorMode
{
//
// Summary:
// The pages of the document will be rendered as color images.
None = 0,
//
// Summary:
// The pages of the document will be rendered as grayscale images.
Grayscale = 1,
//
// Summary:
// The pages of the document will be rendered as black and white images.
BlackAndWhite = 2
}
}
But I could not seem to find this option in Aspose.Pdf. Could anyone please confirm whether this is possible? Thanks.