officeAplication.activate();
IDocumentService documentService = officeAplication.getDocumentService();
IDocument document = documentService.constructNewDocument(
IDocument.WRITER, new DocumentDescriptor());
ITextDocument textDocument = (ITextDocument) document;
boolean useStream = true;
GraphicInfo graphicInfo = null;
String imagePath = "d:\\my_image.gif";
int pixelWidth = 265;
int pixelHeight = 256;
if(!useStream) {
//with url
graphicInfo = new GraphicInfo(imagePath, pixelWidth, true, pixelHeight, true,
VertOrientation.TOP, HoriOrientation.LEFT,
TextContentAnchorType.AT_PARAGRAPH);
}
else {
//with stream
graphicInfo = new GraphicInfo(new FileInputStream(imagePath), pixelWidth,
true, pixelHeight, true, VertOrientation.TOP, HoriOrientation.LEFT,
TextContentAnchorType.AT_PARAGRAPH);
}
ITextContentService textContentService = textDocument.getTextService()
.getTextContentService();
ITextCursor textCursor = textDocument.getTextService().getText()
.getTextCursorService().getTextCursor();
ITextDocumentImage textDocumentImage = textContentService
.constructNewImage(graphicInfo);
textContentService.insertTextContent(textCursor.getEnd(),