static string MigraDocFilenameFromByteArray(byte[] image) { return "base64:" + Convert.ToBase64String(image); }
static byte[] LoadImage(string name) { var assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream(name)) { if (stream == null) throw new ArgumentException("No resource with name " + name); int count = (int)stream.Length; byte[] data = new byte[count]; stream.Read(data, 0, count); return data; } }
byte[] image = LoadImage("ImageFromResource.images.Color8A.bmp"); string imageFilename = MigraDocFilenameFromByteArray(image); Document document = new Document(); Section section = document.AddSection(); section.AddImage(imageFilename);