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

Free Support Forum - aspose.com

Images are written partially

Hi,

I found a nice little bug.

If you are using the document.save with a BufferedInputStream, it seems that the images are not completely written.
After changing to the document.save(String filename) everything was fine. I would say, that you are not calling BufferedInputStream.flush() before close. This can lead to unwritten bytes.

Code:

ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.TIFF);
saveOptions.setTiffCompression(TiffCompression.CCITT_4);
saveOptions.setResolution(300);

try
{
    Document document = new Document(content.getInputStream());
    File tempFile = TemporaryFileManager.createTempFile("word-rendering", ".tiff");
    // FXIME seems that this is not working? document.save(new BufferedOutputStream(new FileOutputStream(tempFile)), saveOptions);
    document.save(tempFile.getAbsolutePath(), saveOptions);
    return Renditions.create(filename, options.target(), tempFile);
}
catch (Exception e)
{
    throw new RenderingException(e);
}

Hi Daniel,

Thanks for your inquiry. Could you please attach the input document you are getting problems with here for testing? I will investigate the issue further on my side and provide you more information.

Best Regards,

See attached the project. The word documents are not written completely.

Hi,

Thanks for your inquiry and sorry for the delayed response. While using the latest version of Aspose.Words i.e. 10.8.0, I was unable to reproduce this issue on my side. Moreover, I would suggest you please visit the following link for downloading and using the latest version of Aspose.Words and let us know your findings:
https://releases.aspose.com/words/net

I hope, this will help.

Best Regards,

Could you test it with my Maven project? The link you have send to me, was for the .NET ones.

Bye,
Daniel

Hi,

Thanks for your inquiry. You can download Aspose.Words for Java 10.8.0 from here:
https://releases.aspose.com/words/java

Best Regards,

I took the 10.8.0 into the project I send you and I’m still able to reproduce it. If you are using a FileOuputStream and no BufferedOutputStream it should work.

I’ m still thinking it is because of a missing InputStream.flush()

Hi
Daniel,

Thanks for the additional information. I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system. Your request has been linked to the appropriate issue and you will be notified as soon as it is resolved. Sorry for inconvenience.

Moreover, I would suggest you please use the following code snippet as a temporary work around:

BufferedInputStream content = new BufferedInputStream(new FileInputStream("C:\test\office2003.doc"));
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.PNG);

saveOptions.setTiffCompression(TiffCompression.CCITT_4);

saveOptions.setResolution(200);

saveOptions.setJpegQuality(80);
Document document = new Document(content);

int pageCount = document.getPageCount();
DocumentBuilder builder = new DocumentBuilder(document);
for (int i = 0; i < pageCount; i++)
{
    saveOptions.setPageIndex(i);
    saveOptions.setPageCount(1);

    File tempFile = File.createTempFile("word-rendering", ".png", new File("."));

    BufferedOutputStream bos = null;
    FileOutputStream fos = new FileOutputStream(tempFile);
    bos = new BufferedOutputStream(fos);

    document.save(bos, saveOptions);
    bos.flush();
}

I hope, this will help.

Best Regards,

Hi Daniel,

Thanks for your nice little bug:) The bug is fixed. The fix will be published within the next release 29.02.2012.

Usually user closes all streams after use. We also are closing all streams in all our unit tests (it’s just a reflex:). So nobody still reported this bug:)

Regards,

The issues you have found earlier (filed as WORDSJAVA-485) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.