Problem in Resolution and saving as pdf file

I want to take an input stream file and then set its resolution and save it as a pdf file…
Please guide me …

Hi Hafsa,


Thank you for contacting Aspose support.

In order to achieve your goal, you have to use two Aspose APIs because Aspose.Imaging APIs do not offer the means to convert the raster image formats to PDF. You can set the resolution of the images using the following piece of Aspose.Imaging code then you have to feed the resultant image to Aspose.Pdf API for the conversion to PDF format.

Java

RasterImage image = (RasterImage)Image.load(sourceFile);
image.setResolution(200, 200);
image.save();


Please feel free to contact us back in case you need our further assistance with Aspose APIs.

Hey this is not working…
I used the following code
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
RasterImage image = (RasterImage)Image.load(“C:/Users/himran/Downloads/emd.jpg”);
image.setResolution(300, 300);
// image.save();
image.save(oStream);
InputStream inStream=new ByteArrayInputStream(oStream.toByteArray());
Pdf pdf = new Pdf();
Section sec = pdf.getSections().add();
aspose.pdf.Image img = new aspose.pdf.Image(sec);
sec.getParagraphs().add(img);
img.getImageInfo().setImageStream(inStream);
pdf.save(“C:/Users/himran/Documents/Resolution-300.pdf”);

And saved a file with with two resolutions seperately… first with setResolution(10,10);
and second with setResolution(300, 300);. But the result for both is the same. I have attached the resultant files. Please answer soon and help me solve this.

Hey this is the image used for the above code/

Hi Hafsa,


Thank you for writing back.

Please note, setting the resolution parameters for the Jpeg image format is different than other raster image formats because Jpeg images store the resolution parameters in EXIF and/or JFIF segments.

Anyway, we have tried to set the resolution of your supplied sample using the following piece of code, and have noticed that image viewers such as IrfanView shows the updates resolution under Image=>Information but in the file properties the updated resolution does not reflect.

Java

ByteArrayOutputStream oStream = new ByteArrayOutputStream();
JpegImage image = (JpegImage)Image.load(sourceFile);
image.getJfif().setYDensity((short) 100);
image.getJfif().setXDensity((short) 100);
image.save(oStream);

We have logged this incident in our bug tracking system under the ticket IMAGING-34119 for further investigation & correction purposes. You have to spare us little time to properly investigate the problem cause on our end. In the meanwhile, we will keep you posted with updates in this regard.

Thankyou for the consideration, i will wait for the updates.

Hi Hafsa,

This is to inform you that we have scheduled the fix for the ticket IMAGING-34119 with the release of Aspose.Imaging for Java 2.7.0. Please note, the upcoming release v2.6.0 has been processed and is ready for publication therefore we had to schedule the aforesaid ticket for the next release. As soon as we plan the release schedule for v2.7.0 of Aspose.Imaging for Java, we will inform you here.

When will my issue will be solved of setting the custome resolution?? mentioned above with detail

Hi Hafsa,


Thank you for contacting back.

As discussed earlier, the ticket attached to this thread is scheduled for fix with the release of Aspose.Imaging for Java 2.7.0. We haven’t yet announced the publication plan for the said release therefore I cannot give you a concrete date for the fix at the moment.

If you can spare me some time, I can discuss this matter with the product team to get you an estimated release schedule for your reference.

Alright Thank you for consideration of the matter.

Hi Hafsa,


Thank you for your patience with us.

This is to inform you that we have completed the investigation of the ticket logged earlier as IMAGING-34119 in reference to setting the resolution for Jpeg image format. The correct code is provided below that you may use with the current revision of Aspose.Imaging for Java 2.6.0.

Java

JpegImage image = (JpegImage)Image.load(source);
image.getJfif().setYDensity((short) 200);
image.getJfif().setXDensity((short) 200);
image.getJfif().setDensityUnits(JfifDensityUnits.PixelsPerInch);
image.save(destination);

As you may observe that the key statement is to assign the correct Density Unit for the JFIF data segment. With the upcoming release of Aspose.Imaging for Java 2.7.0 you can also use the following code to achieve the same.

Java
imageLarge = (JpegImage)Image.load(source); JpegOptions opt = new JpegOptions(); opt.setResolutionSettings(new ResolutionSetting(200.0, 200.0)); imageLarge.save(destination, opt);

The issues you have found earlier (filed as IMAGING-34119) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

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