public ActionResult AsignInfoExport(String editlevel, String applyID) { var agent = AgentLevelApplyService.Instance.QueryAgentApplyByApplyID(applyID); var path = Server.MapPath("~\渠道合作协议模板\渠道合作协议(" + agent.Authlevel + ").doc"); Document doc = new Document(); doc.LoadFromFile(path); doc.Replace("{TradeInfo}", agent.TradeInfo, false, false); doc.Replace("{AreaInfo}", agent.AreaInfo, false, false); var count = AgentLevelApplyService.Instance.QueryAllByDate().Count() + 1; string fieldNumber = "D" + LoginUserID + agent.CreateTime.ToString("yyyyMMdd") + count.ToString("D3"); if (agent.AuthProgress == "已认证") { doc.Replace("{FielNumber}", fieldNumber, false, false); } else { doc.Replace("{FielNumber}", String.Empty, false, false); } doc.Replace("XXXX有限公司", LoginUserName, false, false); var ms = new MemoryStream(); doc.SaveToStream(ms, Spire.Doc.FileFormat.PDF); doc.Close(); doc.Dispose(); return File(ms.ToArray(), "application/pdf;charset=utf-8", agent.Authlevel + "协议证书.pdf"); }