We have document with custom page size.
In order to align objects to left upper corner we tried to remove headers and margins in document, but without success.
Please help to remove any margins from document.
Code we tried (SpireDoc for Java 11.7.0):
- Code: Select all
Document document = new Document("test.docx");
SectionCollection sections = document.getSections();
for (int i = 0; i < sections.getCount(); i++) {
sections.get(i).getHeadersFooters().getHeader().getChildObjects().clear();
sections.get(i).getPageSetup().getMargins().setTop(0f);
sections.get(i).getHeadersFooters().getFooter().getChildObjects().clear();
}
document.saveToFile("test_changed.docx");
}
The source and generated documents are in attachments.
Thanks,
Andrei Chorin