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. :slight_smile:

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:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

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:
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/default.aspx

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() :slight_smile:

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 </span><font color="BLUE" style="background-color: rgb(255, 255, 255); ">=</font><span style="background-color: rgb(255, 255, 255);"> File</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>.</b></font><span style="background-color: rgb(255, 255, 255);">createTempFile</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>(</b></font><font color="PURPLE" style="background-color: rgb(255, 255, 255); ">"word-rendering"</font><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>,</b></font><span style="background-color: rgb(255, 255, 255);"> </span><font color="PURPLE" style="background-color: rgb(255, 255, 255); ">".png"</font><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>,</b></font><span style="background-color: rgb(255, 255, 255);"> </span><font color="RED" style="background-color: rgb(255, 255, 255); "><b>new</b></font><span style="background-color: rgb(255, 255, 255);"> File</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>(</b></font><font color="PURPLE" style="background-color: rgb(255, 255, 255); ">"."</font><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>)</b></font><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>)</b></font><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>;</b></font><span style="background-color: rgb(255, 255, 255);">

</span><span style="background-color: rgb(255, 255, 0);">BufferedOutputStream bos <font color="BLUE">=</font> <font color="RED"><b>null</b></font><font color="BLUE"><b>;</b></font>
FileOutputStream fos <font color="BLUE">=</font> <font color="RED"><b>new</b></font> FileOutputStream<font color="BLUE"><b>(</b></font>tempFile<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font>
bos <font color="BLUE">=</font> <font color="RED"><b>new</b></font> BufferedOutputStream<font color="BLUE"><b>(</b></font>fos<font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font></span><span style="background-color: rgb(255, 255, 255);">

document</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>.</b></font><span style="background-color: rgb(255, 255, 255);">save</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>(</b></font><span style="background-color: rgb(255, 255, 255);">bos</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>,</b></font><span style="background-color: rgb(255, 255, 255);"> saveOptions</span><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>)</b></font><font color="BLUE" style="background-color: rgb(255, 255, 255); "><b>;</b></font><span style="background-color: rgb(255, 255, 255);">

</span><span style="background-color: rgb(255, 255, 0);">bos<font color="BLUE"><b>.</b></font>flush<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font></span><span style="background-color: rgb(255, 255, 255);">

}
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.