Free Support Forum - aspose.com

Change the order of pages (collate)

Can you provide instructions or code for reversing the page order in a document? My objective is to reverse the page order so when the user prints to document, the pages are collated.

I started working on a function but it fails when page is composed of two or more sections.

private static Document ReversePageOrder(Document dstDoc)

{

List<Section> list = new List<Section>();

Document revDoc = new Document();

for (int i = dstDoc.Sections.Count - 1; i >= 0; i--)

{

Section dstSection = dstDoc.Sections[i];

Section newSection = (Section) revDoc.ImportNode(dstSection, true, ImportFormatMode.KeepSourceFormatting);

revDoc.Sections.Add(newSection);

}

return revDoc;

}

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Aspose.Words document represents content and formatting of a document, not its layout into lines and pages. This feature is called pagination and it is not released yet. Please see FAQ for more information.

Your code just reverses sections in your document, but section can contain several pages.

Also there is printer option for reversing the page order during printing.

Best regards.