Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Overwriting pdf

$
0
0
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. 
As an example code, if I do this aspose creates a blank file:
com.aspose.words.Document doc = new com.aspose.words.Document("c:/users/prog2/desktop/trololo.rtf");
doc.save("c:/users/prog2/desktop/trololo.pdf");
com.aspose.pdf.Document doc1 = new com.aspose.pdf.Document("c:/users/prog2/desktop/trololo.pdf");
doc1.save("c:/users/prog2/desktop/trololo.pdf");
But if I do this, it works fine:
com.aspose.words.Document doc = new com.aspose.words.Document("c:/users/prog2/desktop/trololo.rtf");
doc.save("c:/users/prog2/desktop/trololo.pdf");
com.aspose.pdf.Document doc1 = new com.aspose.pdf.Document("c:/users/prog2/desktop/trololo.pdf");
doc1.save("c:/users/prog2/desktop/tralala.pdf");

I've also tried to put some wait times between to make sure that instructions do not step each other or something but still nothing.
 

Viewing all articles
Browse latest Browse all 3131

Trending Articles