|
public static void 图片()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
LayoutManager lm = LayoutManager.Current;
Layout lo = tr.GetObject(lm.GetLayoutId(lm.CurrentLayout), OpenMode.ForRead) as Layout;
PlotInfo pi = new PlotInfo();
pi.Layout = lo.ObjectId;
PlotSettings ps = new PlotSettings(lo.ModelType);
ps.CopyFrom(lo);
PlotSettingsValidator pv = PlotSettingsValidator.Current;
pv.SetPlotType(ps, Autodesk..DatabaseServices.PlotType.Extents);
pv.SetUseStandardScale(ps, true);
pv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
pv.SetPlotCentered(ps, true);
pv.SetPlotConfigurationName(ps, "DWF6 ePlot.pc3", "ANSI_A_(8.50_X_11.00_Inches)");
pi.OverrideSettings = ps;
PlotInfoValidator piv = new PlotInfoValidator();
piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
piv.Validate(pi);
if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
{
using (PlotEngine pe = PlotFactory.CreatePublishEngine())
{
PlotProgressDialog ppd = new PlotProgressDialog(false, 1, true);
using (ppd)
{
ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "打印进度");
ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "取消打印");
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;
ppd.OnBeginPlot();
ppd.IsVisible = true;
pe.BeginPlot(ppd, null);
pe.BeginDocument(pi, doc.Name, null, 1, true, "f:\\abc");
ppd.set_PlotMsgString(PlotMessageIndex.Status, "plotting" + doc.Name + "-" + lo.LayoutName);
ppd.OnBeginSheet();
ppd.LowerSheetProgressRange = 0;
ppd.UpperSheetProgressRange = 100;
ppd.SheetProgressPos = 0;
PlotPageInfo ppi = new PlotPageInfo();
pe.BeginPage(ppi, pi, true, null);
pe.BeginGenerateGraphics(null);
pe.EndGenerateGraphics(null);
pe.EndPage(null);
ppd.SheetProgressPos = 100;
ppd.OnEndSheet();
pe.EndDocument(null);
ppd.PlotProgressPos = 100;
ppd.OnEndPlot();
pe.EndPlot(null);
}
}
}
tr.Commit();
}
Application.ShowAlertDialog("运行完毕");
}
以上是我打印作业的源码,基本是照抄.net开发指南的,可为什么执行代码后在f盘并没有找到生成的图片。尤为奇怪的是我想调查对话框时,提示“已经有一个打印或发布作业在后台处理……”字样。实在快崩溃了,帮帮忙啊高手!
|
|