var imgdata = "";
using (var fs = new FileStream(dlg.FileName, FileMode.OpenOrCreate))
{
fs.Seek(0, SeekOrigin.Begin);
byte[] bs = new byte[fs.Length];
int log = Convert.ToInt32(fs.Length);
fs.Read(bs, 0, log);
imgdata = Convert.ToBase64String(bs);
}
var f = new FileInfo(dlg.FileName);
var rpt = m_CurrentDesigner.Report as PageReport;
var minmetype = "image/" + f.Extension.Substring(1);
var name = f.Name.Substring(0, f.Name.LastIndexOf("."));
var embimage = new EmbeddedImage() { Name = name, MIMEType = minmetype, ImageData = imgdata };
rpt.Report.EmbeddedImages.Add(embimage);
var image = new GrapeCity.ActiveReports.PageReportModel.Image();
image.Name = "test";
image.DataElementName = S_BACKIMAGE_NAME;
image.MIMEType = minmetype;
image.Source = ImageSource.Embedded;
image.Value = name;
image.Left = "0cm";
image.Width = "16cm";
image.Height = "24cm";
image.ZIndex = 0;
rpt.Report.Body.ReportItems.Add(image);
报错
|
|