1

Based on "Hello World" using OpenOffice 3 sample code I have managed to create the Open Office text file from C#. But I still couldn't find a way to set page size and margins. Any clue how this can be done?

Thank you

Community
  • 1
  • 1
Sandra S.
  • 181
  • 1
  • 3
  • 22

1 Answers1

1

I finally found out, so if anyone needs in the future, the code is here:

XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)xComponent;
XNameContainer xPageStyleCollection = (XNameContainer)xSupplier.getStyleFamilies().getByName("PageStyles").Value;
XPropertySet xPropertySet = (XPropertySet)xPageStyleCollection.getByName("Default").Value;
xPropertySet.setPropertyValue("LeftMargin", new Any((Int32)(5000))); //mm
xPropertySet.setPropertyValue("RightMargin", new Any((Int32)(9000))); // (1/100)mm
xPropertySet.setPropertyValue("TopMargin", new Any((Int32)(6000))); //(1/100)mm
xPropertySet.setPropertyValue("BottomMargin", new Any((Int32)(7000))); //(1/100)mm
xPropertySet.setPropertyValue("Width", new Any((Int32)(25000))); //(1/100)mm
xPropertySet.setPropertyValue("Height", new Any((Int32)(21000))); //(1/100)mm
Dipen Panchasara
  • 13,480
  • 5
  • 47
  • 57
Sandra S.
  • 181
  • 1
  • 3
  • 22