Converting TIFF to PDF loses colours


#1

Using Imaging 18.9 for Java.
Converting TIFF to PDF. Colours in image are not preserved. Lots of dark colours all become black.

Code and sample attached.

Document doc = new Document();
Page page = doc.getPages().add();
java.io.FileInputStream fs = new java.io.FileInputStream(inputPath);
page.getPageInfo().getMargin().setBottom(0);
page.getPageInfo().getMargin().setTop(0);
page.getPageInfo().getMargin().setLeft(0);
page.getPageInfo().getMargin().setRight(0);

com.aspose.pdf.Image pdfImage = new com.aspose.pdf.Image();
page.getParagraphs().add(pdfImage);
pdfImage.setImageStream(fs);

//Using Aspose Imaging to grab image width and height
TiffImage image = (TiffImage) com.aspose.imaging.Image.load(inputPath);

int x = image.getWidth();
int y = image.getHeight();

double ratio;

if(x>y){
ratio = (double) y / (double) x;
if(x > 600){
y = (int) (ratio * 600);
x = 600;
}
}else{
ratio = (double) x / (double) y;
if(y > 600){
x = (int) (ratio * 600);
y = 600;
}
}

page.setCropBox(new Rectangle(0, 0, x, y));
doc.save(outputPath);

Colorful_Night-en.tif.zip (1.1 MB)
Colorful_Night-en.pdf (1.5 MB)


#2

@simon.wiseman,

I have worked with sample project shared by you. For further investigation can you please share working sample project along with environment details so that we may help you out.


#3

Code and sample already provided. The environment is Oracle JDK 10 on Windows 10, and it’s using Aspose Words 18.10 for Java as well as Imaging 18.9.


#4

@simon.wiseman,

I have observed the sample code shared by you and I think you are using Aspose.PDF for Java 18.10 and Aspose.Imaging for Java 18.9. We are investigating the issue and will get back to you as soon as possible.


#5

@simon.wiseman

We have tested the scenario where you were generating PDF file by loading TIFF using Aspose.Imaging and converting it using Aspose.PDF. We have observed the same issue which you have stated in your first post. Therefore, we have logged it as PDFJAVA-38109 in our issue tracking system for the sake of correction. We will further investigate it in details and keep you informed with its rectification status. Please be patient and spare us little time.

We are sorry for the inconvenience.


#6

The issues you have found earlier (filed as PDFJAVA-38109) have been fixed in Aspose.PDF for Java 18.11.