Make function return Image rather than PictureRun

This commit is contained in:
Dolan
2018-08-02 21:14:53 +01:00
parent 2d12f6e54c
commit 31fdf08c27
2 changed files with 8 additions and 15 deletions

View File

@ -1,7 +1,7 @@
// http://officeopenxml.com/WPdocument.php
import { IMediaData } from "file/media";
import { XmlComponent } from "file/xml-components";
import { Paragraph, PictureRun } from "../paragraph";
import { Image, Paragraph } from "../paragraph";
import { Table } from "../table";
import { Body } from "./body";
import { SectionPropertiesOptions } from "./body/section-properties/section-properties";
@ -57,18 +57,11 @@ export class Document extends XmlComponent {
return table;
}
public addDrawing(pictureParagraph: Paragraph): void {
this.body.push(pictureParagraph);
}
public createDrawing(imageData: IMediaData): Image {
const image = new Image(imageData);
this.addParagraph(image);
public createDrawing(imageData: IMediaData): PictureRun {
const paragraph = new Paragraph();
const run = new PictureRun(imageData);
paragraph.addRun(run);
this.addDrawing(paragraph);
return run;
return image;
}
get Body(): Body {

View File

@ -10,7 +10,7 @@ import { FootNotes } from "./footnotes";
import { HeaderWrapper } from "./header-wrapper";
import { Media } from "./media";
import { Numbering } from "./numbering";
import { Bookmark, Hyperlink, Paragraph, PictureRun } from "./paragraph";
import { Bookmark, Hyperlink, Image, Paragraph } from "./paragraph";
import { Relationships } from "./relationships";
import { Styles } from "./styles";
import { ExternalStylesFactory } from "./styles/external-styles-factory";
@ -125,7 +125,7 @@ export class File {
return this.document.createTable(rows, cols);
}
public createImage(filePath: string): PictureRun {
public createImage(filePath: string): Image {
const mediaData = Media.addImage(this, filePath);
return this.document.createDrawing(mediaData);
}
@ -135,7 +135,7 @@ export class File {
return this;
}
public createImageFromBuffer(buffer: Buffer, width?: number, height?: number): PictureRun {
public createImageFromBuffer(buffer: Buffer, width?: number, height?: number): Image {
const mediaData = Media.addImageFromBuffer(this, buffer, width, height);
return this.document.createDrawing(mediaData);
}