Cyan tint after converting PDF to image

Hi, we are experimenting this issue (PDFNEWNET-33306) with Aspose.PDF for .NET v 10.3.0, which is the newer version we can get because our license allows free upgrades until 4/21/2015. In our workflow, we convert individual pages of a PDF document to TIFF files, this is the portion of code where this is happening:

 public static void ConvertPDFPageToTIFF(Document pdfDocument, int pageNumber, string outputPath) 
    {
        JpegDevice jpgDevice = new JpegDevice(new Resolution(96), 100);

        using (MemoryStream imageStream = new MemoryStream())
        {
            jpgDevice.Process(pdfDocument.Pages[pageNumber], imageStream);

            System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream);

            ImageCodecInfo codecInfo = GetEncoder(ImageFormat.Tiff);

            EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, 100L);

            EncoderParameter compresionParam = new EncoderParameter(Encoder.Compression, (long)EncoderValue.CompressionLZW);

            EncoderParameters encoderParameters = new EncoderParameters(2);

            encoderParameters.Param[0] = qualityParam;

            encoderParameters.Param[1] = compresionParam;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                image.Save(memoryStream, codecInfo, encoderParameters);

                File.WriteAllBytes(outputPath, memoryStream.ToArray());
            }
        }
    }

    private static ImageCodecInfo GetEncoder(ImageFormat format)
    {

        ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();

        foreach (ImageCodecInfo codec in codecs)
        {
            if (codec.FormatID == format.Guid)
            {
                return codec;
            }
        }
        return null;
    }

Usage:

       string outputPath = @"D:\Temp\";

        FileInfo file = new FileInfo("D:\\Temp\test.pdf");

        using (FileStream fs = file.OpenRead())
        {
            Document pdfDocument = new Document(fs);

            foreach (var page in pdfDocument.Pages)
            {
                ConvertPDFPageToTIFF(page, outputPath);
            }
        }

Here’s the original .pdf file
test.pdf (2.7 MB)
And this is the result:
test.jpg (21.5 KB)

Thanks in advance

@lmarzetti

We tried converting your PDF document into JPG format using following code snippet as it seems from your shared information that you are using JpgDevice. We did not notice any issue on our side. We used Aspose.PDF for .NET 20.11 for testing as it is always recommended to use the latest version.

PDF to JPG

var fs = new FileStream(dataDir + "test.pdf", FileMode.Open);
Document pdfDocument = new Document(fs);
foreach (Page page in pdfDocument.Pages)
{
 using (FileStream imageStream = new FileStream(dataDir + "image" + page.Number + ".jpg", FileMode.Create))
 {
  Resolution resolution = new Resolution(300);
  JpegDevice jpegDeviceLarge = new JpegDevice(resolution, 100);
  jpegDeviceLarge.RenderingOptions.InterpolationHighQuality = true;
  jpegDeviceLarge.RenderingOptions.UseNewImagingEngine = true;
  jpegDeviceLarge.Process(page, imageStream);
 }
}

Would you please try using the latest version of the API and if you still face any issues, please let us know. Furthermore, please try using the following code snippet to generate TIFF from PDF documents and share your feedback with us if the issue still persists:

var document = new Document(dataDir + "test.pdf");
Resolution resolution = new Resolution(300);
TiffSettings tiffSettings = new TiffSettings()
{
 Compression = CompressionType.LZW,
 SkipBlankPages = false,
 Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp,
 //Brightness = 0.80f
 Shape = ShapeType.Portrait
};
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
tiffDevice.RenderingOptions = new RenderingOptions()
{
 SystemFontsNativeRendering = true,
 //UseNewImagingEngine = true
 UseFontHinting= true,
 ConvertFontsToUnicodeTTF = true
};
tiffDevice.Process(document, 1, 1, dataDir + "test20.11.tiff");

Thank you for testing this, Asad!

We are currently on version v10 and upgrading is not really an options for us at this point.

You mentioned earlier that this was fixed a while back in version v9, correct? So why is this still happening in v10?

@appdev.mmo

Sometimes the issue is related to specific PDF document and is resolved only for that file. Furthermore, the issues reported in earlier versions of the API are fixed in the latest version. Would you however please confirm if you are converting your file to JPG or TIFF because you have shared a JPG file in your first post as an output.

We just ran some more tests using the code you provided and the issue is still happening for us, unfortunately.

@appdev.mmo

While converting your PDF file into TIFF format, we have observed that the output image was turned into Black. We used the same code snippet that we shared earlier with Aspose.PDF for .NET 20.11. Therefore, we have logged an issue as PDFNET-49104 in our issue tracking system for the sake of correction.

We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.