public byte[] GetDocImage(string DocXml) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(DocXml); frmText document = new frmText(); document.MyDoc.Locked = true; document.MyDoc.PageHeader = new Dictionary <string, string>(); document.MyDoc.PageHeader.Add("姓名", "张三"); document.MyDoc.PageHeader.Add("科别", "内科"); document.MyDoc.PageHeader.Add("床号", "11"); document.MyDoc.PageHeader.Add("病区", "12"); document.MyDoc.PageHeader.Add("住院号", "111111"); document.MyDoc.PageHeader.Add("性别", "男"); document.MyDoc.PageHeader.Add("入院时间", "2013-01-01"); document.MyDoc.PageHeader.Add("年龄", "22"); //document.MyDoc.Us.InpatientInfo=new Bifrost.InPatientInfo(); //document.MyDoc.Us.InpatientInfo.Patient_Name = "张三"; //document.MyDoc.Us.InpatientInfo = doc.user; document.MyDoc.Us.Tid = 7017004; //document.MyDoc.Locked = true; document.MyDoc.FromXML(doc.DocumentElement, true); string[] strs; System.Drawing.Image[] imgs = document.MyDoc.GetDocForImages(out strs); System.IO.MemoryStream ms = new System.IO.MemoryStream(); imgs[0].Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); document.Dispose(); return(ms.ToArray()); } catch { return(null); } }
/// <summary> /// /// </summary> /// <param name="DocXml"></param> /// <param name="pageindex"></param> /// <param name="pagescount"></param> /// <param name="pageheads"></param> /// <returns></returns> public byte[] GetDocImage(string DocXml, int pageindex, ref int pagescount, string[] pageheads) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(DocXml); frmText document = new frmText(); document.MyDoc.Locked = true; document.MyDoc.PageHeader = new Dictionary <string, string>(); /* * 页眉 */ for (int i = 0; i < pageheads.Length; i++) { document.MyDoc.PageHeader.Add(pageheads[i].Split(',')[0], pageheads[i].Split(',')[1]); } document.MyDoc.Us.Tid = 7017004; document.MyDoc.FromXML(doc.DocumentElement, true); string[] strs; System.Drawing.Image[] imgs = document.MyDoc.GetDocForImages(out strs); pagescount = imgs.Length; System.IO.MemoryStream ms = new System.IO.MemoryStream(); imgs[pageindex - 1].Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); document.Dispose(); return(ms.ToArray()); } catch { return(null); } }