Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
What is this page about?
This page describes how to insert an image using NPOI.
This example inserts an image from a file at a specified position and size
C#
using Aspose.Words;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("test");
var widthEmus = (int)(400.0 * 9525);
var heightEmus = (int)(300.0 * 9525);
builder.InsertImage("../../image/HumpbackWhale.jpg", widthEmus, heightEmus);
doc.Save("test.docx");
XWPFRun.addPicture is used to add an image to document.
C#
using NPOI.XWPF.UserModel;
XWPFDocument doc = new XWPFDocument();
XWPFParagraph p2 = doc.CreateParagraph();
XWPFRun r2 = p2.CreateRun();
r2.SetText("test");
var widthEmus = (int)(400.0 * 9525);
var heightEmus = (int)(300.0 * 9525);
using (FileStream picData = new FileStream("../../image/HumpbackWhale.jpg", FileMode.Open, FileAccess.Read))
{
r2.AddPicture(picData, (int)PictureType.PNG, "image1", widthEmus, heightEmus);
}
using (FileStream sw = File.Create("test.docx"))
{
doc.Write(sw);
}
Download Insert Image form any of the below mentioned social coding sites:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.