Transparency issue while converting Tif to PDF

Hi,

I am using aspose PDF and aspose imaging to convert a multi page Tiff files into PDF files. I am Using following approach…
- Load the Tiff file using aspose imaging
- get each frame of tiff file
- add each image frame in to a PDF
- save the pdf
The Tiff file has a transparent background. When i convert it to PDF the transparent background is converted into black color background,… i have attached sampled input and output files for reference.
Following is the code

com.aspose.pdf.Document lDocument = new com.aspose.pdf.Document();
FileInputStream pInputStream = new FileInputStream(new File(“strike.tif”));
FileOutputStream pOutputStream = new FileOutputStream(new File(“Strike.tif.pdf”));
TiffImage multiImage = (TiffImage) Image.load(pInputStream);
for (TiffFrame tiffFrame : multiImage.getFrames())
{
OutputStream lOutputStream = new ByteArrayOutputStream();
// If i save this png file on disk, the transparency is maintained.
tiffFrame.save(lOutputStream,new PngOptions());
byte[] lImageBytes = ((ByteArrayOutputStream)lOutputStream).toByteArray();
lOutputStream.close();
// Select active frame.
InputStream in = new ByteArrayInputStream(lImageBytes);
Page page = lDocument.getPages().add();
BufferedImage lBImage = ImageIO.read(in);
com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();

// Set the image file stream
image1.setBufferedImage(lBImage);
// Set margins so image will fit, etc.
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);
double currentImageHeight = ConvertUtil.pixelToPoint(lBImage.getHeight());
double currentImageWidth = ConvertUtil.pixelToPoint(lBImage.getWidth());

page.getPageInfo().setHeight(currentImageHeight);
page.getPageInfo().setWidth(currentImageWidth);
// Add the image into paragraphs collection of the section
page.getParagraphs().add(image1);
}
lDocument.processParagraphs();
lDocument.save(pOutputStream);


Hi Dhawal,


Thanks for your inquriy. I have converted your shared TIFF to PDF using Aspose.Pdf for Java 11.4.0 and unable to notice the reported issue. Please download and try latest version of Aspose.Pdf for Java, it will resolve the issue.

We are sorry for the inconvenience caused.

Best Regards,

Hi,

I tried it with aspose PDF 11.4.0, but the issue is still there. Have you used the same code because your output file has different page size as compare to my. PFA is the output with 11.4.0…

FYI…I am using aspose imaging 3.1. if that makes any difference…

Hi Dhawal,


I am sorry for the inconvenience. I have converted TIFF to PDF using Aspose.Pdf. However I have noticed that Aspose.Imaging is not honoring transparency in conversion. So I am moving your post to the Aspose.Imaging forum, my colleague from Aspose.Imaging will look into the issue and will guide you accordingly.

Best Regards,
Hi Dhawal,

Thank you for your inquiry.

Aspose.Imaging API provides the feature to change the background color of a PNG image that has transparent background. Please visit the URL Changing Background color of a Transparent PNG Image for details on how to change the background color of a PNG image.

Feel free to contact us in case you have further query or comments.

Hi Dhawal,

In addintion to previous email. We have investigated the issue. We are able to notice the issue. The issue has been logged into our system with ID IMAGING-35363. Our product team will look into this issue. We will update you about the progress via this forum thread.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.