//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingGrapeCity.Documents.Word;usingGrapeCity.Documents.Imaging; namespaceDsWordWeb.Demos{// This sample demonstrates how to add a JPEG image to a document.publicclassPictureAdd {publicGcWordDocumentCreateDocx() {GcWordDocument doc = newGcWordDocument(); // Load picture data:var picBytes = File.ReadAllBytes(Path.Combine("Resources", "Images", "road.jpg"));// Create a GcBitmap so that we can find out the native picture size:var image = newGcBitmap(picBytes);// Scale picture size to fill the width of the page:var width = doc.Body.Sections.Last.PageSetup.ClientWidth;var height = image.Height * (width / image.Width); // Add an inline picture that fills the page width:var pars = doc.Body.Sections.First.GetRange().Paragraphs;var par = pars.Add("Picture sized to fill the page:");var run = par.GetRange().Runs.Last; run.GetRange().Texts.AddBreak();// Add picture, specifying its mime type:var pic = run.GetRange().Pictures.Add(picBytes, "image/jpeg"); pic.Size.Width.Value = width; pic.Size.Height.Value = height; pars.Add("The End."); // Done:return doc; } }}