function printTask(obj) { var rowData = $("#tb").DataTable().row($(obj).parents('tr')[0]).data(); var url = "/Material/PrintContract"; var inputs = ''; $('
').appendTo('body').submit().remove();}
后台:
public FileResult PrintContract(string conid){ MemoryStream ms = new FileHelper().PrintContractNew(mesContract, detailsEntity, pnEntity.FirstOrDefault(), cuInfo, filiale, cuInuser, sysUser, dtReturn); return File(ms, "application/pdf");}
private static void ReKey(Range range, object model) { if (model == null) return; Type t = model.GetType(); PropertyInfo[] pi = t.GetProperties(); foreach (PropertyInfo p in pi) { var v = p.GetValue(model, null); string va = ""; if (v != null) { if (v.GetType() == typeof(DateTime) || v.GetType() == typeof(Nullable)) { va = DateTime.Parse(v.ToString()).ToString("yyyy-MM-dd"); } else { va = v.ToString(); } } FindReplaceOptions op = new FindReplaceOptions(); op.FindWholeWordsOnly = false; range.Replace("$" + p.Name + "$", va, op); //range.Replace("$" + p.Name + "$", va); } }
private static MemoryStream GetMeoryStreamByFileStream(string filePath, Document doc) { if (!File.Exists(filePath)) return null; using (FileStream stream = File.OpenRead(filePath)) { if (stream == null) return null; MemoryStream ms = new MemoryStream(); doc.Save(ms, SaveFormat.Pdf); ms.Flush(); ms.Seek(0, SeekOrigin.Begin); return ms; } }
暂时没有评论,来抢沙发吧~