Hi, I’m using aspose to convert some files from several different other formats into .pdf in this case. Up to this point, it’s all good. The problem comes when after converting the documents whith aspose.words I try to optimize the size of the images within those .pdf using aspose.pdf and its OptimizationOptions. In any case, to put it simple, the issue is that whenever I try to open a file convert it, then save it to a path and then load it into another document, optimize it and finally save it again overwriting the first one aspose does strange things like saving a blank file. However if instead the second time I save the document to a different location the process it’s done correctly. I’ve looked for a method to close() whichever stream aspose creates but I haven’t seen any, don’t know if this is done automatically or not or if I’m doing something wrong.
Hi Sergio,
Hi Sergio,
Hi Nayyer,
Hi Sergio,
Yes, it is better to save RTF to PDF as stream and then load the PDF from stream instead of loading from the disk. This way the PDF file will be saved to disk only once and you will not see this issue. Following code can be used for this purpose.
com.aspose.words.Document doc = new com.aspose.words.Document("c:/users/prog2/desktop/trololo.rtf");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />
doc.save(byteArrayOutputStream, com.aspose.words.SaveFormat.PDF);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
com.aspose.pdf.Document doc1 = new com.aspose.pdf.Document(byteArrayInputStream);
doc1.save("c:/users/prog2/desktop/trololo.pdf");
Best Regards,
Hi Sergio,Sergio PC:Hi, I’m using aspose to convert some files from several different other formats into .pdf in this case. Up to this point, it’s all good. The problem comes when after converting the documents whith aspose.words I try to optimize the size of the images within those .pdf using aspose.pdf and its OptimizationOptions. In any case, to put it simple, the issue is that whenever I try to open a file convert it, then save it to a path and then load it into another document, optimize it and finally save it again overwriting the first one aspose does strange things like saving a blank file.
I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWJAVA-34790. We
will investigate this issue in details and will keep you updated on the status
of a correction. <o:p></o:p>
We apologize for your inconvenience.
The issues you have found earlier (filed as PDFNEWJAVA-34790) have been fixed in Aspose.Pdf for Java 10.4.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.