How to set the page size and orientation?

Hi,


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:

[Java]
// load Visio
Diagram diagram = new Diagram(“C:/tmp/test.vsdx”);
// set height of the page
diagram.getPages().getPage(“Page-1”).getPageSheet().getPageProps().getPageHeight().setValue(8);
// set width of the page
diagram.getPages().getPage(“Page-1”).getPageSheet().getPageProps().getPageWidth().setValue(11);
// set orientation of the page
diagram.getPages().getPage(“Page-1”).getPageSheet().getPrintProps().getPrintPageOrientation().setValue(PrintPageOrientationValue.PORTRAIT);

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


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

Hi,

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();

license.setLicense("Aspose.Diagram.lic");
Diagram result = new Diagram(
"C:/Users/lihu.server2003/Desktop/MyFolder/test_orient.vsd");
for (Object obj : result.getPages()) {
Page page = (Page) obj;
page.getPageSheet().getPrintProps().getPrintPageOrientation()
.setValue(PrintPageOrientationValue.LANDSCAPE);
}
result.save(
"C:/Users/lihu.server2003/Desktop/MyFolder/test_orient.vdx",
SaveFileFormat.VDX);
}

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:

[Java]
// 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
page.getPageSheet().getPageProps().getPageHeight().setValue(width);
page.getPageSheet().getPageProps().getPageWidth().setValue(height);
}
// 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.