ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / ILayoutFactory Interface / CreateLayout Method / CreateLayout(Double,Double,LinearUnit,Boolean,Double) Method
The width of the page layout in page units.
The height of the page layout in page units.
Specify the linear units.
An optional boolean to show rulers on the layout.
An optional double to specify smallest ruler division.
Example

In This Topic
    CreateLayout(Double,Double,LinearUnit,Boolean,Double) Method
    In This Topic
    Creates a layout using a simple set of parameters. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Overloads Function CreateLayout( _
       ByVal width As Double, _
       ByVal height As Double, _
       ByVal units As LinearUnit, _
       Optional ByVal showRulers As Boolean, _
       Optional ByVal smallestRulerDivision As Double _
    ) As Layout

    Parameters

    width
    The width of the page layout in page units.
    height
    The height of the page layout in page units.
    units
    Specify the linear units.
    showRulers
    An optional boolean to show rulers on the layout.
    smallestRulerDivision
    An optional double to specify smallest ruler division.

    Return Value

    Returns Layout or a null.
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run.
    Example
    CreateLayout_WITH_WD_AND_HT
    //This example creates a new layout using a minimum set of parameters.
    
    //Added references
    using ArcGIS.Desktop.Layouts;                    
    using ArcGIS.Desktop.Framework.Threading.Tasks; 
    using ArcGIS.Desktop.Core;
    
    public class CreateLayoutEx1
    {
      async public static Task<Layout> CreateBasicLayout(double width, double height, LinearUnit units, string LayoutName)
      {
        Layout layout = null;
        await QueuedTask.Run(() =>
        {
          layout = LayoutFactory.Instance.CreateLayout(width, height, units);
          layout.SetName(LayoutName);
        });
    
        //Open the layout in a pane on the UI!
        await ProApp.Panes.CreateLayoutPaneAsync(layout);
    
        return layout;
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also