<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic change programmatically orientation of page layout c# in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-programmatically-orientation-of-page-layout/m-p/1242130#M9192</link>
    <description>&lt;P&gt;Hello, Esri Team&lt;/P&gt;&lt;P&gt;I trying to create programmatically in &lt;STRONG&gt;ArcGIS Pro SDK C#&lt;/STRONG&gt;, a Button that create and open a Page Layout ; I already could create and open the page layout but I can’t find the code to change the Page orientation (Portrait, landscape) in the classes (CIMPage Class, Layout Class, LayoutFactory Class).&lt;/P&gt;&lt;P&gt;Does exist some class that I can use to change the orientation property of the Page Layout?.&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{

Layout newLayout = await QueuedTask.Run&amp;lt;Layout&amp;gt;(() =&amp;gt;
            {
                // Create a new CIM page
                CIMPage newPage = new CIMPage();

                // Add properties
                newPage.Width = 17;
                newPage.Height = 11;
                newPage.Units = LinearUnit.Inches;

                // Add rulers
                newPage.ShowRulers = true;
                newPage.SmallestRulerDivision = 0.5;
                              
                // Apply the CIM page to a new layout and set name
                newLayout = LayoutFactory.Instance.CreateLayout(newPage);
                newLayout.SetName("Layout Carta");
                
                return newLayout;
            });

            var layoutPane = await ProApp.Panes.CreateLayoutPaneAsync(newLayout);

            MessageBox.Show("Layout Creado.");

        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 16 Dec 2022 20:15:58 GMT</pubDate>
    <dc:creator>Ruben_DarioCalero_Clavijo</dc:creator>
    <dc:date>2022-12-16T20:15:58Z</dc:date>
    <item>
      <title>change programmatically orientation of page layout c#</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-programmatically-orientation-of-page-layout/m-p/1242130#M9192</link>
      <description>&lt;P&gt;Hello, Esri Team&lt;/P&gt;&lt;P&gt;I trying to create programmatically in &lt;STRONG&gt;ArcGIS Pro SDK C#&lt;/STRONG&gt;, a Button that create and open a Page Layout ; I already could create and open the page layout but I can’t find the code to change the Page orientation (Portrait, landscape) in the classes (CIMPage Class, Layout Class, LayoutFactory Class).&lt;/P&gt;&lt;P&gt;Does exist some class that I can use to change the orientation property of the Page Layout?.&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{

Layout newLayout = await QueuedTask.Run&amp;lt;Layout&amp;gt;(() =&amp;gt;
            {
                // Create a new CIM page
                CIMPage newPage = new CIMPage();

                // Add properties
                newPage.Width = 17;
                newPage.Height = 11;
                newPage.Units = LinearUnit.Inches;

                // Add rulers
                newPage.ShowRulers = true;
                newPage.SmallestRulerDivision = 0.5;
                              
                // Apply the CIM page to a new layout and set name
                newLayout = LayoutFactory.Instance.CreateLayout(newPage);
                newLayout.SetName("Layout Carta");
                
                return newLayout;
            });

            var layoutPane = await ProApp.Panes.CreateLayoutPaneAsync(newLayout);

            MessageBox.Show("Layout Creado.");

        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 20:15:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-programmatically-orientation-of-page-layout/m-p/1242130#M9192</guid>
      <dc:creator>Ruben_DarioCalero_Clavijo</dc:creator>
      <dc:date>2022-12-16T20:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: change programmatically orientation of page layout c#</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-programmatically-orientation-of-page-layout/m-p/1242199#M9195</link>
      <description>&lt;P&gt;To change page orientation set the page height to the page width and the width to the height.&lt;/P&gt;&lt;P&gt;You then have two choices:&lt;/P&gt;&lt;P&gt;Set the changed page back on the layout &lt;U&gt;and resize all page content&lt;/U&gt; to "fit" on the changed page orientation - or - (edit - this option is available at 3.1)&lt;/P&gt;&lt;P&gt;Resize the page and &lt;U&gt;leave page content "as is"&lt;/U&gt; - potentially page content may no longer fit on the page after a page resize but their dimensions and positions are unchanged (this option is available at 3.0 and 2.x)&lt;/P&gt;&lt;P&gt;Here's a snippet u can fiddle with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void SwitchPageOrientation() {

 if (LayoutView.Active == null)
   return;
 var layout = LayoutView.Active.Layout;
     
 QueuedTask.Run(() =&amp;gt; {
   var page = layout.GetPage();
   //what is the orientation?
   var orientation = page.Height &amp;gt; page.Width ? PageOrientation.Portrait :
           PageOrientation.Landscape;
   //TODO - use orientation as needed

   //switch portrait-&amp;gt;landscape or vice versa
   var wd = page.Width;
   var ht = page.Height;

   page.Height = wd;
   page.Width = ht;

   //Available at 3.1
   layout.SetPage(page, true);//resize the page elements
   //Available at 3.0 and 2.x
   //layout.SetPage(page);&amp;lt;-- use this flavor for no element resizing
   //layout.SetPage(page, false);&amp;lt;-- or set the resize flag false
 });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 02:50:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/change-programmatically-orientation-of-page-layout/m-p/1242199#M9195</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-12-17T02:50:16Z</dc:date>
    </item>
  </channel>
</rss>

