Checking and Correcting transparent Images in the PDF

Hi Team,

We have implemented the check to find the transparent images and flatten them in the PDF. But there is no any feature to Flatten the image in the PDF. As per the intellisense we are only getting the option to delete the image.

I’m providing the below code I’m using to check and correct the transparent images.

Document pdfDocument = new Document((inputStream));
for (int i = 1; i < pageCount + 1; i++)
{
if (pdfDocument.Pages[i].Resources.Images.Count > 0)
{
for (int j = 1; j < pdfDocument.Pages[i].Resources.Images.Count + 1; j++)
{
XImage xImage = pdfDocument.Pages[i].Resources.Images[j];
if (xImage.ContainsTransparency)
{
// Here I’ve to flatten the image in the PDF
pdfDocument.Pages[i].Resources.Images.Delete(j);
}
}

}
}
Also please let us know if there is any other option to do this task.

Regards,
Ishan Adarsh

Hi Ishan,


Thanks for your inquriy. I am afraid Aspose.Pdf does not support feature to remove transparency from images. However you may achieve your requirements with the collaboration of Aspose.Pdf and Aspose.imaging. You may extract the transparent image and use Aspose.Imaging to remove its transparency by changing image background and replace original image in the PDF document using Aspose.Pdf. Hopefully it will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Team,

Thanks for your quick response. Your proposed solution is not working in our scenario.

Basically we have to correct all the transparent images in the PDF that can be in any form e.g. watermark too. If we would save the image and replace it would change the opacity and also the style of the watermark.

I need assistance how we can correct the transparent images in the PDF and flatten them in the PDF without effecting the PDF style.

Also I’m attaching the sample PDF which we are using for our testing purpose.

Regards,
Ishan Adarsh

Hi Ishan,


Thanks for your feedback. We will appreciate it if you please share your intended output PDF sample here. It will help us to understand your requirement exactly, so we will guide you accordingly.

Best Regards,

Hi Team,

Thanks for your reply. I implemented your solution for fixing up the transparency issue in PDF which goes like this :
1. Extract the images from the PDF using Aspose Imaging.
2. Replace the transparent images by removing the transparency from the extracted image.

The above didn’t resolved my issue as in the output file the images totally differs when compared to the actual input file. Also for cross testing I used Adobe PRO for removing the transparency and the output was totally different compared to what Aspose generated for us.

I am attaching all the three files for your reference.

1. pdf with Transparent image.pdf
2. File Generated Through Aspose.pdf
3.
Transparent image ADOBE fixup.pdf

Please Help,

Regards,
Ishan Adarsh

Hi Ishan,


Thanks for sharing the details. After initial investigation we have logged a new feature request PDFNEWNET-40875 to flattening the transparent images in our issue tracking system. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Hi Team,

Thanks for your response and logging this new feature in APOSE. We have already initiated the purchase of ASPOSE Tool from our side (Company Mercer). I need a confirmation till when this feature would be available in ASPOSE. This is the second feature I’ve requested for. First was a bug that is “Converting PDF to PDF/A Standards”. The requirement document is already signed and purchase is in progress. If in case these features are not supported by your tool I would be in a big trouble. Please confirm a TAT for the availability of the feature, so that I can assure the management who are responsible to the purchase of the tool.

Regards,
Ishan Adarsh

Hi Ishan,


Thanks for your inquiry. As we have recently logged the feature requests so we can not share any ETA with you until our product team completes the issues investigation. We have recorded your concern and will notify you as soon as we made some significant progress towards implementation of your requested features.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNET-40875) have been fixed in Aspose.PDF for .NET 24.8.