Fix referenceId +1 error and spelling mistakes
Add demo
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
// http://officeopenxml.com/WPheaders.php
|
||||
import { IMediaData } from "file/media";
|
||||
import { IMediaData, Media } from "file/media";
|
||||
import { Relationships } from "file/relationships";
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
import { Paragraph, PictureRun } from "../paragraph";
|
||||
import { Table } from "../table";
|
||||
import { HeaderAttributes } from "./header-attributes";
|
||||
|
||||
export class Header extends XmlComponent {
|
||||
constructor() {
|
||||
constructor(private readonly media: Media, private readonly relationships: Relationships) {
|
||||
super("w:hdr");
|
||||
this.root.push(
|
||||
new HeaderAttributes({
|
||||
@ -58,9 +59,13 @@ export class Header extends XmlComponent {
|
||||
this.root.push(paragraph);
|
||||
}
|
||||
|
||||
public createDrawing(imageData: IMediaData): void {
|
||||
this.addDrawing(imageData);
|
||||
|
||||
return;
|
||||
public createImage(image: string): void {
|
||||
const mediaData = this.media.addMedia(image, this.relationships.RelationshipCount);
|
||||
this.relationships.createRelationship(
|
||||
mediaData.referenceId,
|
||||
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
||||
`media/${mediaData.fileName}`,
|
||||
);
|
||||
this.addDrawing(mediaData);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user