Hi team,
I am using Aspose.Diagram for Python via .Net with a temporary license. aspose-diagram-python==26.1
I am reading a vsdx file which has multiple pages. There is a particular page which I need to move towards end of the document. I tried updating the page.id to diagram.pages.count+1 but the page still shows up at the front instead of back.
Kindly advise
@Ak78808
You’re trying to move a specific page to the end of a VSDX file, and changing the Page.Id alone does not change the page’s position in the document.
Possible way to reorder pages
# diagram is an Aspose.Diagram.Diagram instance
page_to_move = diagram.Pages[page_index] # zero‑based index of the page you want to move
# Remove it from its current location
diagram.Pages.Remove(page_to_move)
# Append it as the last page (or insert at the desired index)
diagram.Pages.Add(page_to_move) # adds to the end
# or
# diagram.Pages.Insert(diagram.Pages.Count, page_to_move)
After re‑adding the page, save the diagram:
diagram.Save("output.vsdx", Aspose.Diagram.SaveFileFormat.VSDX)
Why this may work
The visual order of pages in a Visio document is generally determined by the order of objects in the Diagram.Pages collection rather than by the Page.Id value. Removing a page and inserting it at a different index changes its position in that collection, which should be reflected when the file is saved.
If this approach does not give the expected result, please share a minimal code snippet that shows how you load the diagram and identify the page you want to move, so we can look into the behavior with Aspose.Diagram v26.1.
@Ak78808
Please try this sample code for python,thanks:
diagram = Diagram(os.path.join(sourceDir, 1.vsdx))
temp = diagram.pages[0]|
diagram.pages.remove(temp)
diagram.pages.add(temp)
#Save diagram in the VSDX format|
diagram.save(os.path.join(outputDir, out.vsdx), SaveFileFormat.VSDX)