Converting PDF to JPEG/TIF C# results in black images

When converting some PDFs to JPG or TIF, a black image file is generated.

So far, this has only occurred with PDFs created with ‘Simple Scan’ that contain an image.

I have included example files in the attachment.

We are using Aspose.PDF version 25.7 for .NET 4.0.
Sample_0001.pdf (34.3 KB)

Sample_0002.jpg (26.8 KB)

@MartinMorris

It sounds like you’re encountering an issue where converting certain PDFs to JPEG or TIFF results in black images, particularly with PDFs created using ‘Simple Scan’. This can occur due to various reasons, such as the way the images are encoded in the PDF or the settings used during conversion.

Cause: The problem may stem from the encoding of images in the PDF or potential corruption in the PDF files.

Solution: Here are some steps you can take to troubleshoot and potentially resolve the issue:

  1. Update Aspose.PDF: You’re using version 25.7, which is quite old. Consider updating to the latest version of Aspose.PDF, as many bugs and issues are fixed in newer releases.

  2. Check PDF Content: Ensure that the PDF files you are trying to convert are not corrupted and that they contain valid image data. Sometimes scanned PDFs may have issues that lead to conversion problems.

  3. Adjust Conversion Settings: When converting, you can specify different settings for the image quality and resolution. Here’s a sample code snippet to convert a PDF to JPEG with specified resolution:

    string dataDir = @"YOUR_DATA_DIRECTORY";
    string pdfFile = @"YOUR_PDF_FILE.pdf";
    
    using (Document pdfDocument = new Document(Path.Combine(dataDir, pdfFile)))
    {
        Resolution resolution = new Resolution(300);
        JpegDevice jpegDevice = new JpegDevice(resolution);
        
        for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
        {
            using (FileStream jpegStream = new FileStream($"{dataDir}image{pageCount}_out.jpeg", FileMode.Create))
            {
                jpegDevice.Process(pdfDocument.Pages[pageCount], jpegStream);
            }
        }
    }
    
  4. Use TiffDevice for TIFF Conversion: If you’re converting to TIFF, ensure you’re using the TiffDevice class with appropriate settings. Here’s an example:

    TiffSettings tiffSettings = new TiffSettings
    {
        Compression = CompressionType.None,
        Depth = ColorDepth.Default,
        Shape = ShapeType.Landscape
    };
    TiffDevice tiffDevice = new TiffDevice(new Resolution(300), tiffSettings);
    tiffDevice.Process(pdfDocument, dataDir + "output.tiff");
    
  5. Test with Different PDFs: Try converting other PDFs to see if the issue is specific to the ones created with ‘Simple Scan’. This can help isolate the problem.

Next Steps: If these steps do not resolve the issue, please provide more details about the specific PDFs and any error messages you might be receiving.

Let me know if this helps!

Now I’m confused, because Aspose.PDF version 25.7.0 is the latest version.
I’ve already tried converting the file in various ways.
The suggestions didn’t help.

@MartinMorris
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-60410

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thank you for provided information. I checked and issue is indeed present, seems like a bug. You’ll be notified when this issue will be resolved

I would like to point out that the problem did not occur when testing with Aspose.PDF version 19.6.0.

@MartinMorris
I’ll add this information in task description