Hi,
I have a weird issue with a shape getting truncated after the document has been saved by Aspose as a DOCX.
Several of our clients, whose’ company branding has a yellow stripe along the bottom of the page, has on several occasions uploaded a docx that isn’t rendered properly when saved as a PDF or PNG.
I have reduced the docx to a bare minimum. It now only contains the stripe (Shape) which is contained inside a Group running long the bottom of the page. The below code (using aspose-words:17.9:jdk16) loads the original document, then resaves it as DOCX, DOC, and DOCX again. The PDF output the first docx resaved file has a trimmer shaped, but after the document got resaved as DOC, reloaded from the new file and then again saved as a DOCX the PDF output of the second DOCX is now correct.
import com.aspose.words.Document;
import com.aspose.words.License;
import java.io.FileInputStream;
public class DocxSavingBug {
public static void main(String... args) {
try {
String dir = "C:\\temp\\aspose\\";
new License().setLicense(new FileInputStream(dir + "Aspose.Words.lic"));
Document doc = new Document(dir + "doc-with-footer.docx");
doc.save(dir + "out-from-original.pdf");
doc.save(dir + "doc-with-footer-resaved.docx");
doc = new Document(dir + "doc-with-footer-resaved.docx");
doc.save(dir + "out-from-resaved-docx.pdf");
doc.save(dir + "doc-with-footer-resaved.doc");
doc = new Document(dir + "doc-with-footer-resaved.doc");
doc.save(dir + "out-from-resaved-doc.pdf");
doc.save(dir + "doc-with-footer-resaved2.docx");
doc = new Document(dir + "doc-with-footer-resaved2.docx");
doc.save(dir + "out-from-resaved-docx2.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}
See the attached zip containing all the output PDFs.
aspose.zip (39.8 KB)
It appears that saving as DOCX/OOXML corrupts something. I have tried the same with FLAT_OPC, OOXML, DOCM and all results were the same.
This saving issue results can be verified in MS Word by forcing it to re-save the shape object. Merely re-saving the Document is insufficient:
- open the original Word Docx,
- right-click the shape (be careful not to select the group) ,
- select “More Layout Options …”
- click OK (without actually having made any change)
- then save the doc and run the code above again. The PDF output is now correct for all cases.
Please fix, as I don’t want to have to create an intermediate DOC file.
Regards,
Daniel