protected override void PrintPreview(ToolStripButton sender) { Model.Info_tmp info = this.ucTmpList1.CurrentSelectValue as Model.Info_tmp; if (info == null || info.Parts.Count == 0) { return; } DocBuilder docBuilder = new DocBuilder(info); DocBuilder.PrintDocPreview(docBuilder.ToStream(), Doc.DocBuilder.ReportName); //Aspose.Words.Document doc = new Aspose.Words.Document(docBuilder.ToStream()); ////Aspose.Words.Rendering.AsposeWordsPrintDocument printDocument = new Aspose.Words.Rendering.AsposeWordsPrintDocument(doc); //using (System.Drawing.Printing.PrintDocument printDoc = Miles.Coro.Common.Print.PrintConfigManager.ApplyPrintSettings(new Aspose.Words.Rendering.AsposeWordsPrintDocument(doc), Doc.DocBuilder.ReportName)) //{ // PrintPreviewDialog previewDlg = new PrintPreviewDialog(); // previewDlg.Document = printDoc; // previewDlg.ShowInTaskbar = true; // previewDlg.MinimizeBox = true; // previewDlg.PrintPreviewControl.Zoom = 1.5d; // previewDlg.WindowState = FormWindowState.Maximized; // previewDlg.ShowDialog(); //} }
private void GetAndSaveTmpVars() { long tmpId = this.InfoTmp.Tmp_Id; List <string> parms = null; DocBuilder docBuilder = new DocBuilder(this.InfoTmp); using (DocX document = DocX.Load(docBuilder.ToStream())) { string regEx = "\\$\\{[^\\$\\{\\}]*\\}"; parms = document.FindUniqueByPattern(regEx, RegexOptions.IgnoreCase); //string filename = System.IO.Path.Combine("Report", "tmp.docx"); //Doc.DocBuilder1.SetPageMargin(document); //document.SaveAs(filename); } if (!manager.SaveTmpVars(tmpId, parms)) { MessageBox.Show("模板提取变量失败"); } }