Community
I'm having trouble setting PrintParameter values. The following code runs, and the PrintSetup saves, but the PageOrientation value never changes to Portrait. What am I missing? Thanks.
Document activeDoc = commandData.Application.ActiveUIDocument.Document;
var trans = new Transaction(activeDoc, "PrintSettings");
trans.Start();
activeDoc.PrintManager.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = PageOrientationType.Portrait;
activeDoc.PrintManager.PrintSetup.SaveAs("MyPrintSettings");
PrintSetting myPs = activeDoc.GetPrintSettingIds(). Select(activeDoc.get_Element). Cast<PrintSetting>(). FirstOrDefault(printSetting => printSetting.Name == "MyPrintSettings");
activeDoc.PrintManager.PrintSetup.CurrentPrintSetting = myPs; trans.Commit();
Solved! Go to Solution.
Solved by BobbyC.Jones. Go to Solution.
A quick perusal through the ADN knowledge base and the answer is found. Apparently each call to a Document's PrintManager property generates a new PrintManager object. It needs to be cached and all calls should be made to the cached object.
PrintManager pm = activeDoc.PrintManager;
pm.PrintSetup.CurrentPrintSetting.PrintParameters.PageOrientation = PageOrientationType.Portrait;