We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Tif to pdf convert error: Unable to read values for Xresolution tag

hi friends,


i use aspose pdf java 9.0. when i try to convert tif file to pdf i get an error like this;

Exception in thread “main” java.lang.IllegalStateException: Unable to read values for Xresolution tag. Message : Cannot read 8 bytes from the stream.
at com.aspose.ms.c.g.at.c(Unknown Source)
at com.aspose.ms.c.g.ce.e(Unknown Source)
at com.aspose.ms.c.g.ce.d(Unknown Source)
at com.aspo…
…a(Unknown Source)
at aspose.pdf.Pdf.save(Unknown Source)
at com.aspose.Test.SplitTiff2Pdf.tif2Pdf(SplitTiff2Pdf.java:76)
at com.aspose.Test.SplitTiff2Pdf.main(SplitTiff2Pdf.java:87)

error occuer in pdf1.save() line. i use win7 x64 and jdk 1.7, editor is Spring Tool Suite, how can i resolve this cause could you help me please, my java class and tif file in attachment

thanks for all supports,

Best regards.

Hi,


Thanks for contacting support.

I have tested the scenario and have observed the same problem that IllegalStateException is being generated when converting tifFile0.tif file to PDF format. For
the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34185. We will
investigate this issue in details and will keep you updated on the status of a
correction.

We apologize for your inconvenience.


PS, however when trying to convert tifFile.tif, the resultant file is properly being generated. For your reference, I have also attached the resultant PDF generated over my end.

hi Nayyer,


by the way i split the tiff file with your product so occur this problem, but when i tried tif file without splitting, did not occur any problem. i think this cause may be help you.

thanks for help,

good works.

Hi,


Thanks for sharing the details.

Can you please share some details regarding above stated point “splitting the TIFF file”. Do you use our Aspose.Imaging API to split the TIFF image or do you mean the conversion of TIFF image to PDF format. Please share some details so we may answer accordingly.

hi Nayyer,


thanks for reply firstly, i can tyr to explain that,

first of all,
i split a multi tif image with your product aspose image after try to convert pdf file all pages one by one with your product aspose pdf, so i got an error Exception in thread “main” java.lang.IllegalStateException: Unable to read values for Xresolution tag. Message : Cannot read 8 bytes from the stream.

but when i convert multi tif file to pdf directly did not get an error like above.

here is my tiff split code

TiffImage multiImage = (TiffImage) Image.load(myDir + myFile);
int frameCounter = 0;
for (TiffFrame tiffFrame : multiImage.getFrames()) {
multiImage.setActiveFrame(tiffFrame);
TiffOptions createOptions = new TiffOptions();
createOptions.setSource(new FileCreateSource(myDir + “Frame-” + frameCounter + “.tif”));
TiffImage tiffImage = (TiffImage) Image.create(createOptions, tiffFrame.getWidth(), tiffFrame.getHeight());
TiffFrame frame = TiffFrame.copyFrame(tiffFrame);
tiffImage.addFrame(frame);
tiffImage.setActiveFrame(frame);
tiffImage.removeFrame(0);
tiffImage.save();
frameCounter++;
}

and here my convert pdf code

public static List tif2Pdf(List fileList) {
List returnList = new ArrayList();
for (File file : fileList) {

String fullPath = FilenameUtils.getFullPath(file.getPath());
String baseName = FilenameUtils.getBaseName(file.getPath());

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
sec1.getParagraphs().add(img1);

img1.getImageInfo().setImageFileType(ImageFileType.Tiff);
// img1.getImageInfo().setIsBlackWhite(true);
img1.getImageInfo().setFile(file.getPath());
img1.getImageInfo().setTiffFrame(-1);
img1.setImageScale(0.95F);

pdf1.save(fullPath + baseName + “.pdf”);
returnList.add(new File(fullPath + baseName + “.pdf”));
}
return returnList;
}

i hope this can be explanation for you thanks for support,

best regards.

Hi,


Thanks for sharing the details.

I have tested the scenario using above stated code and have observed that when trying to convert TIFF image generated by Aspose.Imaging for Java, the exception occurs. Whereas when we try to convert the original TIFF image (before splitting it to single frame images), the conversion is performed without any problem. The details have been shared with development team and they will definitely consider this information during the resolution of this problem.