Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
When I use this code below, my printing is not producing any different output, even if I make changes to zoom, colour etc. Is there something I am missing or not setting properly?
[Transaction(TransactionMode.Manual)]
public class PrintSettingsCommand : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document OpenDoc = App.CurrentDocument;
PrintManager printManager = OpenDoc.PrintManager;
printManager.PrintSetup.CurrentPrintSetting = printManager.PrintSetup.InSession;
printManager.SelectNewPrintDriver(App.BASPalette.cboPrinter.SelectedItem as string);
printManager.PrintToFile = true;
printManager.PrintRange = PrintRange.Select;
printManager.PrintToFileName = string.Format(@"C:\PDF\{0}.pdf", OpenDoc.ProjectInformation.Name);
IPrintSetting printSettings = printManager.PrintSetup.CurrentPrintSetting;
ViewSheetSetting viewSheetSetting = printManager.ViewSheetSetting;
ViewSet viewSet = new ViewSet();
for (int i = 0; i < App.BASPalette.lvwSheets.SelectedItems.Count; i++)
{
WSPSheet sheet = App.BASPalette.lvwSheets.SelectedItems[i] as WSPSheet;
if (sheet != null)
{
if (sheet.View.CanBePrinted)
{
viewSet.Insert(sheet.View);
}
}
}
printSettings.PrintParameters.PageOrientation = PageOrientationType.Landscape;
printSettings.PrintParameters.PaperSize = App.BASPalette.cboPaperSize.SelectedItem as PaperSize;
printSettings.PrintParameters.ZoomType = ZoomType.Zoom;
printSettings.PrintParameters.Zoom = 100;
printSettings.PrintParameters.ColorDepth = ColorDepthType.GrayScale;
using (Transaction transaction = new Transaction(OpenDoc))
{
transaction.Start("Set in-session views");
viewSheetSetting.InSession.Views = viewSet;
transaction.Commit();
}
printManager.PrintSetup.CurrentPrintSetting = printSettings;
printManager.CombinedFile = true;
printManager.Apply();
OpenDoc.Print(viewSet, true);
return Result.Succeeded;
}
}
Solved! Go to Solution.