Convert PDF to TIFF get null error

Thanks for the good news!


Our developer downloaded the conversion jar and tested with default and “300” resolution. No difference was found about the size of converted file.

Please advise what we might have done wrong.

Thanks!
Catherine

Hello Catherine,

Thank you for coming back.

Could you please share with us your code example that you use and we will investigate it. Also it will be useful if you share with us your file example, because we have tested your files that you shared with us previously and we don't got this issue with "resolution" parameter.

Please come back to us with these details and we will be glad to help you.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

Using the latest beta version from the link you provided on 10/6 for PDF to TIFF conversion, the setResolution() does not have any effect. The converted TIFF document is very blur. We tried resolution 72, 300, even very large number like 3000, 300000. It does not make any difference. File size remain unchanged.


Below is the conversion code. I only provided the methods, not the whole Java class. Source PDF file and converted TIFF file are attached. Note, input is 700 KB high resolution PDF, output becomes 5 MB low resolution TIFF.

Look forward to your guidance on how to resolve the issue.

Thanks!
Catherine

------------------------------------------------------------------------------------------------

public byte[] convertToTiff(String fileName, byte[] fileContents) {
ConversionHandler conversionHandler = new ConversionHandler(
new IConfig() {
@Override
public String getStoragePath() {
return null; // not required
}

@Override
public String getLicensePath() {
return PropertyManager
.getProperty(“groupdocs.api.lic.path”);
}

@Override
public String getFileSavePath() {
return null; // not required
}
});

ImageSaveOptions imageSaveOptions = new ImageSaveOptions();
imageSaveOptions.setSaveFileType(ImageSaveOptions.TIFF);
imageSaveOptions.setHeight(800); // This works - reduced converted file size.
imageSaveOptions.setWidth(600); // This works.
imageSaveOptions.setResolution(300); // This does not make any difference.

InputStream inStream = new ByteArrayInputStream(fileContents);
try {
ArrayList tiffStreamList = conversionHandler
.convertToImage(inStream, fileName, imageSaveOptions);

return mergTiff(tiffStreamList);
} catch (Exception ex) {
throw new RuntimeException(
“Error converting input document to tiff”, ex);
} finally {
try {
inStream.close();
} catch (IOException e) {
// so;
}
}
}

private byte[] mergTiff(ArrayList tiffStreamList) {
BufferedImage image[] = new BufferedImage[tiffStreamList.size()];
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try {
for (int i = 0; i < tiffStreamList.size(); i++) {

InputStream tiffStream = new ByteArrayInputStream(
tiffStreamList.get(i).toByteArray());
tiffStreamList.get(i).close();

ImageDecoder decoder = ImageCodec.createImageDecoder(“tiff”,
tiffStream, null);
PlanarImage op = (new NullOpImage(
decoder.decodeAsRenderedImage(0), null, null,
OpImage.OP_IO_BOUND));
image[i] = op.getAsBufferedImage();
tiffStream.close();
}

TIFFEncodeParam params = new TIFFEncodeParam();
ImageEncoder encoder = ImageCodec.createImageEncoder(“tiff”,
outStream, params);
List imageList = new ArrayList();
for (int i = 1; i < image.length; i++) {
imageList.add(image[i]);
}
params.setExtraImages(imageList.iterator());
encoder.encode(image[0]);

return outStream.toByteArray();
} catch (Exception ex) {
throw new RuntimeException(“Error merging the tiff streams”, ex);
} finally {
try {
outStream.close();
} catch (IOException e) {
// so
}
}
}



Hello Catherine,

Thank you for your details.

We have tested the scenario and have managed to reproduce the same issue at our side. Our Product team was informed about it and they will investigate the issue. We will notify you when we will have any results.

We apologize for the inconvenience.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

I would appreciate it very much if you could treat this as high priority.


Thanks!
Catherine
Hello Catherine,

Yes, at the moment our Product team is working on this issue with high priority and doing all our best to fix it.

Could you please specify one more thing . In your previous post you have mentioned, that you tried to convert a file in our Conversion for Cloud service and got small .tiff image (300 KB TIFF), but as you said that in our Conversion for Java library this output image was very big (6 MB TIFF). Will be useful if you share with us this file example and imageSaveOptions that you used for Java library.

These details will help us with fixing the issue.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

I will not share that exact document because it contains patient information.


Let me attach another testing I did today. The original PDF document is 625 KB. Using Cloud App, it was converted to 1.1 MB TIFF. Using Java API, it was converted to 5.6 MB TIFF.

Also noticed, Cloud App conversion took about 5 seconds, Java API took about 10 seconds. Cloud conversion output file is much clearer than Java conversion.

I attached all 3 files: input PDF; cloud app output TIFF; Java output TIFF.

Thanks!
Catherine


Hello Catherine,

Thank you for file examples.

We have tested your scenario and found out that you use your own merge functionality for output files to one .tiff file . Yes when we use your code examples we can reproduce the issue with big file size . But seems this occurs via your merge code, because when we convert your file then we get three single files with total file size as 1 Mb.
Anyway our Product team works on your issue and they will try to find the solution for you.

We will keep you updated

-------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

Hello Evgen,


We need a single TIFF file as output.
- DId we lose the image quality while converting or merging?
- Will you please recommend better approach to merge pages into one file with smaller file size?

Thanks!
Catherine

Hello Catherine,


Thank you for coming back. For merging pdf documents we can suggest you to try to use Aspose.PDF for Java library and follow this article for how to merge pdf. Please try to use this approach an then use result pdf for converting in to the tiff.

Best regards.

Hello Pavel,


Our requirement is to convert various format of documents into TIFF. For example, we need to convert PDF, Word, Excel documents and jpeg, gif image files into TIFF.

The GroupDocs Java conversion API converts multi-page file into multiple single page files of target format - TIFF in our case. We will need to merge the result files into one TIFF file. We will not buy another tool to merge PDF pages into one because this is not what we needed.

I used PDF as an example for the challenges we face. We have 2 issues:

1) Qualify of PDF to TIFF conversion is poor.
2) The converted file size is extremely high. We want to reduce the converted file size.

We observed that the Cloud App conversion does not have the above issues for the same file.

I had updated the forum, chatted with your support staff back and force for many times. I emphasized the urgency of the issue. I hope you guys understand clearly what the issue is. We cannot afford any delay in the solution. Our users will not sign off the solution with a low quality file where you cannot see the signature part clearly.

We need your guidance on how to improve the above issues, I look forward to your advise.

Thanks a lot!
Catherine

By the way, we are using GroupDocs Conversion Java API 1.3.0 beta version downloaded on 10/6 from the link provided by support. The jar file size is: 82,935,607 bytes. This version fixed another issue we have - word conversion error. I believe this version will be released soon.


Thanks!
Catherine

Hello Catherine,


I just now had a conversation with our Product team and have found out next: in the next version of the Conversion will be added next features:
1. Multi page tiff - when you will convert to the tiff you will get one tiff file with several pages instead of several files with one page.
2. Flags to set quality/file size - you will be able to set quality/file size of the result file. Just to notify you - you should know that quality depends on the size and when you will decrease the file size - the quality will decrease too.

Unfortunately I can’t provide any ETA for the release but I can say that it will be towards the end of the month.

Best regards.

Hello Pavel,


As discussed in the chat, I need your help to forward our concerns to your product manager. I hope your team can help us succeed in our project delivery.

Our requirement is to convert various documents (pdf, word, excel, etc) to TIFF format. The documents can be multi pages. We chose your Java conversion API after research. The conversion module is part of a large scale project, which is at UAT stage, approaching release date.

During development and testing, we ran into several exceptions with Java conversion API. With your team’s help, they are all fixed immediately. We appreciate your help on those.

With the 1.3.0 beta version, the conversion function is stabilized, we begin to face/notice image quality and performance issues. The following are issues we hope you can add to version 1.3.0 and hopefully we can get them asap.
- Image conversion quality.
This is a critical issue. You can refer to our uploaded file. The signature part is very blurry.
- Converted TIFF file size.
The file size is extremely big. This sometimes causing OutOfMemoryError.
- Conversion function.
Your Java conversion API convert multi-page document into multiple single page documents. We will have to write code to merge them.
- Compare with your Cloud App conversion.
The Cloud App Conversion works perfectly well. It converts document with good quality, very small size, and returns single file of multiple pages.

I am not sure if we are asking too much. But we depend on your expertise to fix the issues as much as you can.

Please let us know how soon you can fix the issues we face. Let us know your thoughts.

Thanks!
Catherine






Hello Pavel,


Instead of waiting for the release, I would like to get the beta version to try it out. Can we get the beta version as soon as the feature is out? Right now we are using 1.3.0 beta so we no longer get Java exceptions.

I believe the flags you mentioned are imageSaveOptions.setWidth(), setHeight() and setResolution(). This is available in the beta version we downloaded on 10/6. It did not work for us. The setWidth/setHeight make difference to the size, but setResolution does not have any effect. The quality of signature part in converted file remains poor no matter how we set the values. It is a little better with higher width/height, but still not acceptable. All in all, the Cloud App conversion has great quality and small size at the same time. Signature is very clear. Conversion is super quick. We are looking for same level of conversion result in Java API.

The convert to single file feature is very interesting. I hope you can provide us the preview as soon as it comes out. We can try it out and provide our feedback.

So, what is my take today? Am I going to get the latest beta version with some interesting enhancements today? If not, what I can get early next week?

Thanks!
Catherine

Hi,


As we discussed in the live chat I will add the conversation here.

The beta version will be on the next week. Also imageSaveOptions.setWidth(), setHeight() and setResolution(). - these is not the flags about which I mentioned, for multi page tiff will added new flags.

Best regards.

Hi Pavel,


I look forward to the beta version next week - better by Monday. If we cannot get a satisfactory solution asap, we will be forced to look for alternate solutions.

As for the beta, please provide some sample codes. This way we will not spend time figuring out how to use it.

Please also help use the source PDF file I uploaded to test at your end. Make sure the signature part in the converted file is clear.

Thanks!
Catherine

Hello Catherine,

We understand that this issue is important to you and our Product team makes everything possible to provide for you the new beta version today, but we think most likely that it will be available tomorrow.

Also we have investigated your code and found out that you can set this flag (COMPRESSION_DEFLATE) for TIFFEncodeParam class and your output file size will be very small, but the signature for this configuration, will be blurred . Can you please check, does the result file will suit your requirements if you will use this configuration

imageSaveOptions.setWidth(960);
imageSaveOptions.setHeight(1280);

and

TIFFEncodeParam params = new TIFFEncodeParam();
params.setCompression(TIFFEncodeParam.COMPRESSION_DEFLATE);

The file size after merging will be 1.5 Mb. Of course you can further reduce the width and height and get the file size as 715Kb , but you will lose in the image quality.


----------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

Hello Evgen,


Thanks for the sample code!

The file size reduced dramatically. We don’t worry about that now.

The converted image looks better, however still a little blurry. I can’t wait to test out the new version tomorrow. Hopefully the image quality will be better and the signature section will be acceptable.

Thanks for your hard work!
Catherine

Hello Catherine,

We have good news for you.

We have prepared new demo version of the Conversion library for you and I'll send a link on it to your email.

With this new version you can use such merge option:
imageSaveOptions.setMultipageTiff(true); imageSaveOptions.setMultipageTiffCompression(ImageSaveOptions.TIFF_COMPRESSION_LZW);

and I think that you should try to set the Resolution parameter as (100) then you will get acceptable quality of the image.

If you will have more questions please feel free to contact us.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+