Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
ODF .NET
>
Tutorial
>Set page size and orientation
The following example shows you how to set page size and orientation.
C# example
using System; using Independentsoft.Office.Odf; using Independentsoft.Office.Odf.Styles; namespace Sample { class Program { static void Main(string[] args) { TextDocument doc = new TextDocument(); PageLayout pageLayout1 = new PageLayout(); pageLayout1.Name = "Layout1"; pageLayout1.PageLayoutProperties.PrintOrientation = PrintOrientation.Landscape; pageLayout1.PageLayoutProperties.PageHeight = new Size(11.69, Unit.Inch); pageLayout1.PageLayoutProperties.PageWidth = new Size(8.26, Unit.Inch); doc.CommonStyles.AutomaticStyles = new AutomaticStyles(); doc.CommonStyles.AutomaticStyles.PageLayouts.Add(pageLayout1); MasterPage masterPage1 = new MasterPage(); masterPage1.Name = "Standard"; masterPage1.PageLayout = "Layout1"; doc.CommonStyles.MasterStyles = new MasterStyles(); doc.CommonStyles.MasterStyles.MasterPages.Add(masterPage1); doc.Save("c:\\test\\output.odt", true); } } }
VB example
Imports System Imports Independentsoft.Office.Odf Imports Independentsoft.Office.Odf.Styles Module Module1 Sub Main(ByVal args() As String) Dim doc As TextDocument = New TextDocument Dim pageLayout1 As New PageLayout() pageLayout1.Name = "Layout1" pageLayout1.PageLayoutProperties.PrintOrientation = PrintOrientation.Landscape pageLayout1.PageLayoutProperties.PageHeight = New Size(11.69, Unit.Inch) pageLayout1.PageLayoutProperties.PageWidth = New Size(8.26, Unit.Inch) doc.CommonStyles.AutomaticStyles = New AutomaticStyles() doc.CommonStyles.AutomaticStyles.PageLayouts.Add(pageLayout1) Dim masterPage1 As New MasterPage() masterPage1.Name = "Standard" masterPage1.PageLayout = "Layout1" doc.CommonStyles.MasterStyles = New MasterStyles() doc.CommonStyles.MasterStyles.MasterPages.Add(masterPage1) doc.Save("c:\test\output.odt", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*