예제 #1
0
        /// <summary>
        /// 单页预览
        /// </summary>
        /// <param name="layoutId"></param>
        /// <param name="plotArea"></param>
        /// <param name="plotDevice"></param>
        /// <param name="plotCanonicalMeida"></param>
        /// <param name="plotStyle"></param>
        public static void PreviewSinglePage(
            ObjectId layoutId,
            Extents2d plotArea,
            string plotDevice,
            string plotCanonicalMeida,
            string plotStyle
            )
        {
            if (PlotFactory.ProcessPlotState != ProcessPlotState.NotPlotting)
            {
                MessageBox.Show($"当前不能预览,另一个打印任务正在进行中!");
                return;
            }

            using (Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                Layout lo = mFun.m_OpenEntity(layoutId) as Layout;

                if (LayoutManager.Current.CurrentLayout != lo.LayoutName)
                {
                    LayoutManager.Current.CurrentLayout = lo.LayoutName;
                }

                using (PlotProgressDialog ppd = new PlotProgressDialog(true, 1, false))
                {
                    #region 设置进度条信息

                    #endregion 

                    using (PlotEngine pe = PlotFactory.CreatePreviewEngine(0))
                    {
                        //设置打印配置参数
                        PlotInfo pi = SetPlotInfo(lo, plotArea, plotDevice, plotCanonicalMeida, plotStyle, true);

                        pe.BeginPlot(ppd, null);

                        pe.BeginDocument(pi, mCommands.Doc.Name, null, 1, false, "");

                        pe.BeginPage(new PlotPageInfo(), pi, true, null);

                        pe.BeginGenerateGraphics(null);

                        pe.EndGenerateGraphics(null);

                        PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();
                        pe.EndPage(pepi);//结束本页打印,返回预览状态

                        pe.EndDocument(null);

                        pe.EndPlot(null);
                    }
                }
            }
        }
예제 #2
0
        static PreviewEndPlotStatus MultiplePlotOrPreview(PlotEngine pe, bool isPreview, ObjectIdCollection layoutSet, int layoutNumIfPreview, string dirPath, string jobnumber)
        {
            Document             doc = AcApp.DocumentManager.MdiActiveDocument;
            Database             db  = doc.Database;
            PreviewEndPlotStatus ret = PreviewEndPlotStatus.Cancel;
            ObjectIdCollection   layoutsToPlot;

            if (isPreview && layoutNumIfPreview >= 0)
            {
                // Preview is really pre-sheet, so we reduce the
                // sheet collection to contain the one we want
                layoutsToPlot = new ObjectIdCollection
                {
                    layoutSet[layoutNumIfPreview]
                };
            }
            else
            {
                // If we're plotting we need all the sheets,
                // so copy the ObjectIds across
                ObjectId[] ids = new ObjectId[layoutSet.Count];
                layoutSet.CopyTo(ids, 0);
                layoutsToPlot = new ObjectIdCollection(ids);
            }
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                // Create a Progress Dialog to provide info
                // and allow thej user to cancel
                using (PlotProgressDialog ppd = new PlotProgressDialog(isPreview, layoutsToPlot.Count, true))
                {
                    int numSheet = 1;
                    foreach (ObjectId btrId in layoutsToPlot)
                    {
                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
                        Layout           lo  = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

                        // We need a PlotSettings object
                        // based on the layout settings
                        // which we then customize
                        PlotSettings ps = new PlotSettings(lo.ModelType);
                        ps.CopyFrom(lo);

                        // The PlotSettingsValidator helps
                        // create a valid PlotSettings object
                        PlotSettingsValidator psv = PlotSettingsValidator.Current;

                        // We need a PlotInfo object
                        // linked to the layout
                        PlotInfo pi = new PlotInfo
                        {
                            Layout = btr.LayoutId
                        };
                        // Make the layout we're plotting current
                        LayoutManager.Current.CurrentLayout = lo.LayoutName;
                        // We need to link the PlotInfo to the
                        // PlotSettings and then validate it
                        pi.OverrideSettings = ps;
                        PlotInfoValidator piv = new PlotInfoValidator
                        {
                            MediaMatchingPolicy = MatchingPolicy.MatchEnabled
                        };
                        piv.Validate(pi);
                        // We set the sheet name per sheet
                        ppd.set_PlotMsgString(PlotMessageIndex.SheetName, doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1) + " - " + lo.LayoutName);
                        if (numSheet == 1)
                        {
                            // All other messages get set once
                            ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Custom Preview Progress");
                            ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
                            ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
                            ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
                            ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
                            ppd.LowerPlotProgressRange = 0;
                            ppd.UpperPlotProgressRange = 100;
                            ppd.PlotProgressPos        = 0;

                            // Let's start the plot/preview, at last
                            ppd.OnBeginPlot();
                            ppd.IsVisible = true;
                            pe.BeginPlot(ppd, null);

                            // We'll be plotting a single document
                            string file = dirPath + "\\" + jobnumber + " Combined " + DateTime.Now.ToString("MM-dd-yy");
                            pe.BeginDocument(pi, doc.Name, null, 1, !isPreview, file);
                        }

                        // Which may contains multiple sheets
                        ppd.LowerSheetProgressRange = 0;
                        ppd.UpperSheetProgressRange = 100;
                        ppd.SheetProgressPos        = 0;
                        PlotPageInfo ppi = new PlotPageInfo();
                        pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count), null);
                        ppd.OnBeginSheet();
                        pe.BeginGenerateGraphics(null);
                        ppd.SheetProgressPos = 50;
                        pe.EndGenerateGraphics(null);

                        // Finish the sheet
                        PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();
                        pe.EndPage(pepi);
                        ret = pepi.Status;
                        ppd.SheetProgressPos = 100;
                        ppd.OnEndSheet();
                        numSheet++;

                        // Update the overall progress
                        ppd.PlotProgressPos +=
                            (100 / layoutsToPlot.Count);
                    }

                    // Finish the document
                    pe.EndDocument(null);

                    // And finish the plot
                    ppd.PlotProgressPos = 100;
                    ppd.OnEndPlot();
                    pe.EndPlot(null);
                }
            }
            return(ret);
        }
예제 #3
0
        static PreviewEndPlotStatus PlotOrPreview(PlotEngine pe, bool isPreview, ObjectId layout, string dirPath, string jobnumber)
        {
            Document doc = AcApp.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            PreviewEndPlotStatus ret = PreviewEndPlotStatus.Cancel;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                // We'll be plotting the current layout
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(layout, OpenMode.ForRead);
                Layout           lo  = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);

                PlotSettings ps = new PlotSettings(lo.ModelType);
                ps.CopyFrom(lo);

                PlotInfo pi = new PlotInfo
                {
                    Layout = btr.LayoutId
                };

                // Make the layout we're plotting current
                LayoutManager.Current.CurrentLayout = lo.LayoutName;
                // We need to link the PlotInfo to the
                // PlotSettings and then validate it
                pi.OverrideSettings = ps;
                PlotInfoValidator piv = new PlotInfoValidator
                {
                    MediaMatchingPolicy = MatchingPolicy.MatchEnabled
                };

                piv.Validate(pi);

                /*
                 * // We need a PlotInfo object
                 * // linked to the layout
                 * PlotInfo pi = new PlotInfo();
                 * pi.Layout = lo.BlockTableRecordId;
                 *
                 * // We need a PlotSettings object
                 * // based on the layout settings
                 * // which we then customize
                 * PlotSettings ps = new PlotSettings(lo.ModelType);
                 * ps.CopyFrom(lo);
                 *
                 * // The PlotSettingsValidator helps
                 * // create a valid PlotSettings object
                 * PlotSettingsValidator psv = PlotSettingsValidator.Current;
                 *
                 * // We need to link the PlotInfo to the
                 * // PlotSettings and then validate it
                 * pi.OverrideSettings = ps;
                 * PlotInfoValidator piv = new PlotInfoValidator();
                 * piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                 * piv.Validate(pi);*/

                // Create a Progress Dialog to provide info
                // and allow thej user to cancel
                PlotProgressDialog ppd = new PlotProgressDialog(isPreview, 1, true);
                using (ppd)
                {
                    ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Custom Preview Progress");
                    ppd.set_PlotMsgString(PlotMessageIndex.SheetName, doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1));
                    ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
                    ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
                    ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
                    ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
                    ppd.LowerPlotProgressRange = 0;
                    ppd.UpperPlotProgressRange = 100;
                    ppd.PlotProgressPos        = 0;

                    // Let's start the plot/preview, at last
                    ppd.OnBeginPlot();
                    ppd.IsVisible = true;
                    pe.BeginPlot(ppd, null);

                    // We'll be plotting/previewing
                    // a single document
                    string file = dirPath + "\\" + jobnumber + " " + lo.LayoutName + " " + DateTime.Now.ToString("MM-dd-yy");
                    pe.BeginDocument(pi, doc.Name, null, 1, !isPreview, file);

                    // Which contains a single sheet
                    ppd.OnBeginSheet();
                    ppd.LowerSheetProgressRange = 0;
                    ppd.UpperSheetProgressRange = 100;
                    ppd.SheetProgressPos        = 0;
                    PlotPageInfo ppi = new PlotPageInfo();
                    pe.BeginPage(ppi, pi, true, null);
                    pe.BeginGenerateGraphics(null);
                    ppd.SheetProgressPos = 50;
                    pe.EndGenerateGraphics(null);

                    // Finish the sheet
                    PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();
                    pe.EndPage(pepi);
                    ret = pepi.Status;
                    ppd.SheetProgressPos = 100;
                    ppd.OnEndSheet();

                    // Finish the document
                    pe.EndDocument(null);

                    // And finish the plot
                    ppd.PlotProgressPos = 100;
                    ppd.OnEndPlot();
                    pe.EndPlot(null);
                }
                // Committing is cheaper than aborting
                tr.Commit();
            }
            return(ret);
        }
예제 #4
0
        /// <summary>
        /// 执行单一布局打印
        /// </summary>
        /// <param name="engine">打印引擎对象</param>
        /// <param name="layout">要打印的布局</param>
        /// <param name="ps">打印设置</param>
        /// <param name="fileName">打印文件名</param>
        /// <param name="copies">打印份数</param>
        /// <param name="isPreview">是否预览打印</param>
        /// <param name="showProgressDialog">是否显示打印进度框</param>
        /// <param name="plotToFile">是否打印到文件</param>
        /// <returns>返回打印状态</returns>
        public static PreviewEndPlotStatus Plot(this PlotEngine engine, Layout layout, PlotSettings ps, string fileName, int copies, bool isPreview, bool showProgressDialog, bool plotToFile)
        {
            PlotProgressDialog plotDlg = null; //声明一个打印进度框对象

            if (showProgressDialog)            //如果需要显示打印进度框,则创建
            {
                plotDlg = new PlotProgressDialog(isPreview, 1, true);
                //获取去除扩展名后的文件名(不含路径)
                string plotFileName = SymbolUtilityServices.GetSymbolNameFromPathName(fileName, "dwg");
                //在打印进度框中显示的图纸名称:当前打印布局的名称(含文档名)
                plotDlg.set_PlotMsgString(PlotMessageIndex.SheetName, "正在处理图纸:" + layout.LayoutName + "(" + plotFileName + ".dwg)");
            }
            //设置打印的状态为停止
            PreviewEndPlotStatus status = PreviewEndPlotStatus.Cancel;
            PlotInfo             pi     = new PlotInfo(); //创建打印信息

            pi.Layout           = layout.ObjectId;        //要打印的布局
            pi.OverrideSettings = ps;                     //使用ps中的打印设置
            //验证打印信息是否有效
            PlotInfoValidator piv = new PlotInfoValidator();

            piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
            piv.Validate(pi);
            //启动打印进度框
            if (showProgressDialog)
            {
                plotDlg.StartPlotProgress(isPreview);
            }
            engine.BeginPlot(plotDlg, null);//开启打印引擎进行打印任务
            //开始打印文档
            engine.BeginDocument(pi, layout.Database.GetDocument().Name, null, copies, plotToFile, fileName);
            //启动打印图纸进程
            if (plotDlg != null)
            {
                plotDlg.StartSheetProgress();
            }
            //开始打印页面
            PlotPageInfo ppi = new PlotPageInfo();

            engine.BeginPage(ppi, pi, true, null);
            engine.BeginGenerateGraphics(null);//开始打印内容
            //设置打印进度
            if (plotDlg != null)
            {
                plotDlg.SheetProgressPos = 50;
            }
            engine.EndGenerateGraphics(null);//内容打印结束
            //结束页面打印
            PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();

            engine.EndPage(pepi);
            status = pepi.Status;//打印预览结束时的状态
            //终止显示打印图纸进程
            if (plotDlg != null)
            {
                plotDlg.EndSheetProgress();
            }
            engine.EndDocument(null);//文档打印结束
            //终止显示打印进度框
            if (plotDlg != null)
            {
                plotDlg.EndPlotProgress();
            }
            engine.EndPlot(null); //结束打印任务
            return(status);       //打印预览结束时的状态
        }
예제 #5
0
        /// <summary>
        /// 执行多布局打印
        /// </summary>
        /// <param name="engine">打印引擎对象</param>
        /// <param name="layouts">要打印的布局列表</param>
        /// <param name="ps">打印设置</param>
        /// <param name="fileName">打印文件名</param>
        /// <param name="previewNum">预览的布局号,小于1表示打印</param>
        /// <param name="copies">打印份数</param>
        /// <param name="showProgressDialog">是否显示打印进度框</param>
        /// <param name="plotToFile">是否打印到文件</param>
        /// <returns>返回打印状态</returns>
        public static PreviewEndPlotStatus MPlot(this PlotEngine engine, List <Layout> layouts, PlotSettings ps, string fileName, int previewNum, int copies, bool showProgressDialog, bool plotToFile)
        {
            int numSheet = 1;//表示当前打印的图纸序号
            //设置是否为预览
            bool               isPreview = previewNum >= 1 ? true : false;
            Document           doc       = Application.DocumentManager.MdiActiveDocument;
            PlotProgressDialog plotDlg   = null; //声明一个打印进度框对象

            if (showProgressDialog)              //如果需要显示打印进度框,则创建
            {
                plotDlg = new PlotProgressDialog(isPreview, layouts.Count, true);
            }
            //设置打印的状态为停止
            PreviewEndPlotStatus status = PreviewEndPlotStatus.Cancel;
            //重建一个布局列表,因为打印预览只能是单页的
            List <Layout> layoutList = new List <Layout>();

            if (isPreview && previewNum >= 1)            //如果为打印预览
            {
                layoutList.Add(layouts[previewNum - 1]); //只对预览的布局进行操作
            }
            else
            {
                layoutList.AddRange(layouts);     //如果为打印,则需对所有的布局进行操作
            }
            foreach (Layout layout in layoutList) //遍历布局
            {
                PlotInfo pi = new PlotInfo();     //创建打印信息
                pi.Layout = layout.ObjectId;      //要打印的布局
                //要多文档打印,必须将要打印的布局设置为当前布局
                LayoutManager.Current.CurrentLayout = layout.LayoutName;
                pi.OverrideSettings = ps;//使用ps中的打印设置
                //验证打印信息是否有效
                PlotInfoValidator piv = new PlotInfoValidator();
                piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
                piv.Validate(pi);
                if (plotDlg != null)//如果显示打印进度框
                {
                    //获取去除扩展名后的文件名(不含路径)
                    string plotFileName = SymbolUtilityServices.GetSymbolNameFromPathName(doc.Name, "dwg");
                    //在打印进度框中显示的图纸名称:当前打印布局的名称(含文档名)
                    plotDlg.set_PlotMsgString(PlotMessageIndex.SheetName, plotFileName + "-" + layout.LayoutName);
                }
                //如果打印的是第一张图纸则启动下面的操作,以后就不再需要再次进行
                if (numSheet == 1)
                {
                    //启动打印进度框
                    if (showProgressDialog)
                    {
                        plotDlg.StartPlotProgress(isPreview);
                    }
                    engine.BeginPlot(plotDlg, null);//开启打印引擎进行打印任务
                    //开始打印文档
                    engine.BeginDocument(pi, doc.Name, null, copies, plotToFile, fileName);
                }
                //启动打印图纸进程
                if (plotDlg != null)
                {
                    plotDlg.StartSheetProgress();
                }
                //开始打印页面
                PlotPageInfo ppi = new PlotPageInfo();
                engine.BeginPage(ppi, pi, (numSheet == layoutList.Count), null);
                engine.BeginGenerateGraphics(null);//开始打印内容
                //设置打印进度
                if (plotDlg != null)
                {
                    plotDlg.SheetProgressPos = 50;
                }
                engine.EndGenerateGraphics(null);//内容打印结束
                //结束页面打印
                PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();
                engine.EndPage(pepi);
                status = pepi.Status;//打印预览结束时的状态
                //终止显示打印图纸进程
                if (plotDlg != null)
                {
                    plotDlg.EndSheetProgress();
                }
                numSheet++;//将要打印的图纸序号设置为下一个
                //更新打印进程
                if (plotDlg != null)
                {
                    plotDlg.PlotProgressPos += (100 / layouts.Count);
                }
            }
            engine.EndDocument(null);//文档打印结束
            if (plotDlg != null)
            {
                plotDlg.EndPlotProgress(); //终止显示打印进度框
            }
            engine.EndPlot(null);          //结束打印任务
            return(status);                //返回打印预览结束时的状态
        }
예제 #6
0
        /// <summary>
        /// 多页打印/预览函数
        /// </summary>
        /// <param name="pe"></param>
        /// <param name="isPreview"></param>
        /// <param name="plotList"></param>
        /// <param name="sheetNumIfPreview"></param>
        /// <param name="layoutCount"></param>
        /// <param name="plotDevice"></param>
        /// <param name="plotCanonicalMeida"></param>
        /// <param name="plotStyle"></param>
        /// <param name="saveFileName"></param>
        /// <returns></returns>
        private static PreviewEndPlotStatus MultiPlotOrPreview(
        PlotEngine pe,
        bool isPreview,
        Dictionary<Extents2d, ObjectId> plotList,
        int sheetNumIfPreview,
        int layoutCount,//布局总数
        string plotDevice,
        string plotCanonicalMeida,
        string plotStyle,
        string saveFileName
        )
        {
            PreviewEndPlotStatus ret = PreviewEndPlotStatus.Cancel;

            string DocName = mCommands.Doc.Name;
            DocName = DocName.Substring(DocName.LastIndexOf("\") + 1);
            DocName = DocName.Substring(0, DocName.LastIndexOf("."));

            #region 准备打印区域列表plotAreaList
            Dictionary<Extents2d, ObjectId> plotAreaList = new Dictionary<Extents2d, ObjectId>();
            if (isPreview && sheetNumIfPreview >= 0)
            {
                KeyValuePair<Extents2d, ObjectId> kv = plotList.ElementAt(sheetNumIfPreview);
                plotAreaList.Add(kv.Key, kv.Value);//预览只能一个区域 
            }
            else
            {
                plotAreaList = plotList;//打印全部区域
            }
            #endregion

            using (Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                try
                {
                    using (PlotProgressDialog ppd = new PlotProgressDialog(isPreview, plotAreaList.Count, false))
                    {
                        #region 设置进度条显示信息                                    
                        ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "转换进度");
                        ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "本布局转换进度:__/__");
                        ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "总转换进度: __/__");

                        ppd.LowerPlotProgressRange = 0;
                        ppd.UpperPlotProgressRange = plotAreaList.Count;

                        //显示进度条对话框
                        ppd.OnBeginPlot();
                        ppd.IsVisible = true;
                        #endregion

                        int pageNum = 0;//布局打印页计数
                        int layoutPageNum = 0;//当前布局总打印页数(区域数)
                        int sheetNum = 0;//所有打印页计数(打印总区域数)
                        ObjectId layoutId = ObjectId.Null;//当前布局Id

                        Layout lo = null;
                        foreach (KeyValuePair<Extents2d, ObjectId> kv in plotAreaList)
                        {
                            if (kv.Value != layoutId)
                            {
                                layoutId = kv.Value;

                                lo = mFun.m_OpenEntity(layoutId) as Layout;
                                LayoutManager.Current.CurrentLayout = lo.LayoutName;//切换为当前布局,是否必须?!!

                                pageNum = 0;//重置布局页计数

                                layoutPageNum = plotAreaList.Count(a => a.Value == layoutId);

                                ppd.LowerSheetProgressRange = 0;
                                ppd.UpperSheetProgressRange = layoutPageNum;
                            }

                            pageNum++;//布局页计数+1
                            sheetNum++;//总打印区域计数+1                    

                            ppd.set_PlotMsgString(PlotMessageIndex.SheetName, $"{DocName}-{lo.LayoutName}");//打印文件名-布局名

                            //设置打印配置参数
                            PlotInfo pi = SetPlotInfo(lo, kv.Key, plotDevice, plotCanonicalMeida, plotStyle, isPreview);

                            #region 启动打印
                            if (sheetNum == 1)
                            {
                                pe.BeginPlot(ppd, null);

                                pe.BeginDocument(
                                    pi,                                     //打印信息
                                    mCommands.Doc.Name,                     //当前图纸名
                                    null,
                                    1,                                      //打印份数
                                    !isPreview,                             //是否打印至文件
                                    isPreview ? "" : saveFileName           //保存文件名
                                    );
                            }
                            #endregion

                            #region 开始打印
                            ppd.OnBeginSheet();

                            ppd.SheetProgressPos = pageNum;
                            ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, $"本布局转换进度:{pageNum}/{layoutPageNum}");

                            ppd.PlotProgressPos = sheetNum;
                            ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, $"总转换进度:sheetNum}/{plotAreaList.Count}");

                            pe.BeginPage(
                                new PlotPageInfo(),
                                pi,                                 //打印信息
                                sheetNum == plotAreaList.Count,     //是否最后一页
                                null
                                );

                            pe.BeginGenerateGraphics(null);
                            pe.EndGenerateGraphics(null);

                            PreviewEndPlotInfo pepi = new PreviewEndPlotInfo();
                            pe.EndPage(pepi);//结束本页打印,返回预览状态
                            ret = pepi.Status;
                            #endregion
                        }

                        #region 结束打印
                        ppd.OnEndSheet();
                        pe.EndDocument(null);

                        ppd.OnEndPlot();
                        pe.EndPlot(null);
                        #endregion
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception e)
                {
                    MessageBox.Show($"转换为单个PDF文档出错: {e.Message}!\n请选择【单幅分别保存】进行转换。", "转换出错", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    ret = PreviewEndPlotStatus.Cancel;
                }
            }

            return ret;
        }