We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to Apply Default PageSetting to Diagram

Hello Support, I want to apply my default page setting to the diagram on the application load. I tried this as given blow : PageSettings pageSetting = new PageSettings(); pageSetting.Landscape = true; pageSetting.PaperSize.PaperName = "A6"; activeDiagram.View.PageSettings = pageSetting; activeDiagram.View.Update(true); But when i run this code its giving me run time error saying "Can''t change the paper size unless its kind is custom" and when i cannot change the PaperSize.Kind property to custom as it is readonly property. pageSetting.PaperSize.Kind = PaperKind.Custom; Can u suggest me how to apply the these custom page setting properties to the diagram /Ratan

1 Reply

AD Administrator Syncfusion Team December 7, 2005 11:33 PM UTC

Hello Ratan, This is the expected behavior of the .NET Printing infrastructure. You can change the paper size attributes (width/height/papername) only if the PaperSize is a custom type that you created. To specify any of the standard PaperSizes, you will have to get the supported sizes from the PrinterSetting''s PaperSizes collection, and choose the appropriate one. The following code should give you an idea on how to go about this issue, PageSettings pagesetting = new PageSettings(); if(pagesetting.PrinterSettings.IsValid) { PaperSize selectedsize = null; for (int i = 0; i < pagesetting.PrinterSettings.PaperSizes.Count; i++) { PaperSize currentsize = pagesetting.PrinterSettings.PaperSizes[i]; if(currentsize.PaperName == "A6") { selectedsize = currentsize; break; } } if(selectedsize != null) { pagesetting.Landscape = true; activeDiagram.View.PageSettings = pagesetting; activeDiagram.View.RefreshPageSettings(); activeDiagram.View.Update(true); } } This is purely a .NET issue, and you should be able to get more detailed information by referring to the MSDN documentation on the relevant classes. Thanks, Prakash Surendra Syncfusion Inc.,

Loader.
Live Chat Icon For mobile
Up arrow icon