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

Free Support Forum - aspose.com

How to set the page size and orientation?


I want to create a visio file. Need to set the page size and orientation. But I don’t find any api can do this.

Can you help me out?

Hi Hugh,

Thank you for contacting us and using Aspose.Diagram API. Please refer to the following help topics: Add and Connect Visio Shapes and Create an empty Visio Diagram

Please also use the following code for page size and orientation purposes:

// load Visio
Diagram diagram = new Diagram(“C:/tmp/test.vsdx”);
// set height of the page
// set width of the page
// set orientation of the page

// save Visio
diagram.save(“C:/tmp/Output.vsdx”, SaveFileFormat.VSDX);

Please let us know in case of any further assistance or questions.


I try to set the page orientation according to your post above. but still can't change the page to LANDSCAPE type.

I attached the code and the visio file I used to test.

public static void main(String[] args) throws Exception {
License license = new License();

Diagram result = new Diagram(
for (Object obj : result.getPages()) {
Page page = (Page) obj;

Hi Hugh,

Thank you for the details. You’re correct that the PrintPageOrientation property does not act as expected. We’ve logged this problem under ticket id DIAGRAMJAVA-50300 in our bug tracking system. Your post has also been linked to this ticket. We’ll keep you informed regarding any available updates. As a workaround, please set page size by interchanging the values of width and height properties. Please use this sample code:

// load Visio
Diagram result = new Diagram(“C:/AD/test593/test_orient.vsd”);
// iterate through the pages
for (Object obj : result.getPages())
Page page = (Page) obj;
// get height of the page
double height = page.getPageSheet().getPageProps().getPageHeight().getValue();
// get width of the page
double width = page.getPageSheet().getPageProps().getPageWidth().getValue();

// interchange height and width
// save Visio
result.save(“C:/AD/test593/test_orient05.vdx”, SaveFileFormat.VDX);

Hi Hugh,

Thank you for being patient. We have a good news for you that the issue id DIAGRAMJAVA-50300 has now been resolved. If there is no issue in the QA phase, then this fix will be incorporated in the next version 6.1.0 of the Aspose.Diagram for Java API. We'll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as DIAGRAMJAVA-50300) have been fixed in Aspose.Diagram for Java 6.1.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.