We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Landscape converted to portrait issue

Hi Team,

Previously I have faced conversion issues (i.e section break to page break). Now the problem is resolved. But I’m facing a new issue. when I convert section break to page break, Orientation is changed(i.e Landscape to portrait) in the document(.docx). Kindly share your idea, it help us.

Document doc = new Document(interimdoc);

Run pageBreak = new Run(interimdoc, ControlChar.PAGE_BREAK);
while (interimdoc.getSections().getCount() > 1)
{
    Section last = interimdoc.getSections().get(interimdoc.getSections().getCount() - 1);
    Section prev = interimdoc.getSections().get(interimdoc.getSections().getCount() - 2);
    prev.getBody().getLastParagraph().appendChild(pageBreak.deepClone(true));
    last.prependContent(prev);
    prev.remove();
}
interimdoc.save(interim);

Thanks in advance.

@Mahesh39 This is an expected behavior. It is impossible to have different page orientation without section breaks because page orientation and other page setup properties in MS Word documents are set per section.