Removed header-wrapper-2
This commit is contained in:
@ -6,17 +6,17 @@ doc.createParagraph("First Page").pageBreak()
|
|||||||
doc.createParagraph("Second Page");
|
doc.createParagraph("Second Page");
|
||||||
|
|
||||||
|
|
||||||
var pageoneheader = new docx.Paragraph("Running head: My Title").right()
|
var pageoneheader = new docx.Paragraph("Running head: My Title").maxRightTabStop();
|
||||||
//var tab = new docx.TextRun().tab()
|
var tab = new docx.TextRun().tab()
|
||||||
var pageNumber = new docx.TextRun().pageNumber()
|
var pageNumber = new docx.TextRun().pageNumber()
|
||||||
|
|
||||||
//pageoneheader.addRun(tab);
|
pageoneheader.addRun(tab);
|
||||||
pageoneheader.addRun(pageNumber);
|
pageoneheader.addRun(pageNumber);
|
||||||
doc.Header2.addParagraph(pageoneheader);
|
doc.firstPageHeader.addParagraph(pageoneheader);
|
||||||
|
|
||||||
var pagetwoheader = new docx.Paragraph("My Title").maxRightTabStop();
|
var pagetwoheader = new docx.Paragraph("My Title").maxRightTabStop();
|
||||||
|
|
||||||
//pagetwoheader.addRun(tab)
|
pagetwoheader.addRun(tab)
|
||||||
pagetwoheader.addRun(pageNumber)
|
pagetwoheader.addRun(pageNumber)
|
||||||
doc.Header.addParagraph(pagetwoheader)
|
doc.Header.addParagraph(pagetwoheader)
|
||||||
doc.Header = new docx.Paragraph("My Title")
|
doc.Header = new docx.Paragraph("My Title")
|
||||||
|
@ -35,7 +35,7 @@ export class Compiler {
|
|||||||
const xmlFileRelationships = xml(this.formatter.format(this.file.FileRelationships));
|
const xmlFileRelationships = xml(this.formatter.format(this.file.FileRelationships));
|
||||||
const xmlHeader = xml(this.formatter.format(this.file.Header.Header));
|
const xmlHeader = xml(this.formatter.format(this.file.Header.Header));
|
||||||
|
|
||||||
const xmlHeader2 = xml(this.formatter.format(this.file.Header2.Header));
|
const xmlHeader2 = xml(this.formatter.format(this.file.firstPageHeader.Header));
|
||||||
|
|
||||||
const xmlFooter = xml(this.formatter.format(this.file.Footer.Footer));
|
const xmlFooter = xml(this.formatter.format(this.file.Footer.Footer));
|
||||||
const xmlHeaderRelationships = xml(this.formatter.format(this.file.Header.Relationships));
|
const xmlHeaderRelationships = xml(this.formatter.format(this.file.Header.Relationships));
|
||||||
|
@ -4,9 +4,9 @@ import { CoreProperties, IPropertiesOptions } from "./core-properties";
|
|||||||
import { Document } from "./document";
|
import { Document } from "./document";
|
||||||
import { SectionPropertiesOptions } from "./document/body/section-properties/section-properties";
|
import { SectionPropertiesOptions } from "./document/body/section-properties/section-properties";
|
||||||
import { FooterWrapper } from "./footer-wrapper";
|
import { FooterWrapper } from "./footer-wrapper";
|
||||||
import { HeaderWrapper } from "./header-wrapper";
|
import { HeaderWrapper, FirstPageHeaderWrapper } from "./header-wrapper";
|
||||||
|
|
||||||
import { HeaderWrapper2 } from "./header-wrapper2";
|
//import { HeaderWrapper2 } from "./header-wrapper2";
|
||||||
|
|
||||||
import { Media } from "./media";
|
import { Media } from "./media";
|
||||||
import { Numbering } from "./numbering";
|
import { Numbering } from "./numbering";
|
||||||
@ -26,7 +26,7 @@ export class File {
|
|||||||
private readonly fileRelationships: Relationships;
|
private readonly fileRelationships: Relationships;
|
||||||
private readonly headerWrapper: HeaderWrapper;
|
private readonly headerWrapper: HeaderWrapper;
|
||||||
|
|
||||||
private readonly headerWrapper2: HeaderWrapper2;
|
private readonly firstPageHeaderWrapper: FirstPageHeaderWrapper;
|
||||||
|
|
||||||
private readonly footerWrapper: FooterWrapper;
|
private readonly footerWrapper: FooterWrapper;
|
||||||
private readonly contentTypes: ContentTypes;
|
private readonly contentTypes: ContentTypes;
|
||||||
@ -78,7 +78,7 @@ export class File {
|
|||||||
this.media = new Media();
|
this.media = new Media();
|
||||||
|
|
||||||
this.headerWrapper = new HeaderWrapper(this.media);
|
this.headerWrapper = new HeaderWrapper(this.media);
|
||||||
this.headerWrapper2 = new HeaderWrapper2(this.media);
|
this.firstPageHeaderWrapper = new FirstPageHeaderWrapper(this.media);
|
||||||
|
|
||||||
this.footerWrapper = new FooterWrapper(this.media);
|
this.footerWrapper = new FooterWrapper(this.media);
|
||||||
this.contentTypes = new ContentTypes();
|
this.contentTypes = new ContentTypes();
|
||||||
@ -171,11 +171,10 @@ export class File {
|
|||||||
return this.headerWrapper;
|
return this.headerWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get Header2(): HeaderWrapper2 {
|
public get firstPageHeader(): FirstPageHeaderWrapper {
|
||||||
return this.headerWrapper2;
|
return this.firstPageHeaderWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public get Footer(): FooterWrapper {
|
public get Footer(): FooterWrapper {
|
||||||
return this.footerWrapper;
|
return this.footerWrapper;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import { Paragraph } from "./paragraph";
|
|||||||
import { Relationships } from "./relationships";
|
import { Relationships } from "./relationships";
|
||||||
import { Table } from "./table";
|
import { Table } from "./table";
|
||||||
|
|
||||||
export class HeaderWrapper {
|
export class FirstPageHeaderWrapper {
|
||||||
private readonly header: Header;
|
private readonly header: Header;
|
||||||
private readonly relationships: Relationships;
|
private readonly relationships: Relationships;
|
||||||
|
|
||||||
@ -53,3 +53,59 @@ export class HeaderWrapper {
|
|||||||
return this.relationships;
|
return this.relationships;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class HeaderWrapper {
|
||||||
|
private readonly header: Header;
|
||||||
|
private readonly header2: Header;
|
||||||
|
private readonly relationships: Relationships;
|
||||||
|
|
||||||
|
constructor(private readonly media: Media) {
|
||||||
|
this.header = new Header();
|
||||||
|
this.header2 = new Header();
|
||||||
|
this.relationships = new Relationships();
|
||||||
|
}
|
||||||
|
|
||||||
|
public addParagraph(paragraph: Paragraph): void {
|
||||||
|
this.header.addParagraph(paragraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
public createParagraph(text?: string): Paragraph {
|
||||||
|
const para = new Paragraph(text);
|
||||||
|
this.addParagraph(para);
|
||||||
|
return para;
|
||||||
|
}
|
||||||
|
|
||||||
|
public addTable(table: Table): void {
|
||||||
|
this.header.addTable(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public createTable(rows: number, cols: number): Table {
|
||||||
|
return this.header.createTable(rows, cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
public addDrawing(imageData: IMediaData): void {
|
||||||
|
this.header.addDrawing(imageData);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Header(): Header {
|
||||||
|
return this.header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Header2(): Header {
|
||||||
|
return this.header2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Relationships(): Relationships {
|
||||||
|
return this.relationships;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
import { Header2 } from "./header2/header";
|
|
||||||
import { IMediaData, Media } from "./media";
|
|
||||||
import { Paragraph } from "./paragraph";
|
|
||||||
import { Relationships } from "./relationships";
|
|
||||||
import { Table } from "./table";
|
|
||||||
|
|
||||||
export class HeaderWrapper2 {
|
|
||||||
private readonly header: Header2;
|
|
||||||
private readonly relationships: Relationships;
|
|
||||||
|
|
||||||
constructor(private readonly media: Media) {
|
|
||||||
this.header = new Header2();
|
|
||||||
this.relationships = new Relationships();
|
|
||||||
}
|
|
||||||
|
|
||||||
public addParagraph(paragraph: Paragraph): void {
|
|
||||||
this.header.addParagraph(paragraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
public createParagraph(text?: string): Paragraph {
|
|
||||||
const para = new Paragraph(text);
|
|
||||||
this.addParagraph(para);
|
|
||||||
return para;
|
|
||||||
}
|
|
||||||
|
|
||||||
public addTable(table: Table): void {
|
|
||||||
this.header.addTable(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
public createTable(rows: number, cols: number): Table {
|
|
||||||
return this.header.createTable(rows, cols);
|
|
||||||
}
|
|
||||||
|
|
||||||
public addDrawing(imageData: IMediaData): void {
|
|
||||||
this.header.addDrawing(imageData);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get Header(): Header2 {
|
|
||||||
return this.header;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get Relationships(): Relationships {
|
|
||||||
return this.relationships;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
import { XmlAttributeComponent } from "file/xml-components";
|
|
||||||
|
|
||||||
export interface IHeaderAttributesProperties {
|
|
||||||
wpc?: string;
|
|
||||||
mc?: string;
|
|
||||||
o?: string;
|
|
||||||
r?: string;
|
|
||||||
m?: string;
|
|
||||||
v?: string;
|
|
||||||
wp14?: string;
|
|
||||||
wp?: string;
|
|
||||||
w10?: string;
|
|
||||||
w?: string;
|
|
||||||
w14?: string;
|
|
||||||
w15?: string;
|
|
||||||
wpg?: string;
|
|
||||||
wpi?: string;
|
|
||||||
wne?: string;
|
|
||||||
wps?: string;
|
|
||||||
cp?: string;
|
|
||||||
dc?: string;
|
|
||||||
dcterms?: string;
|
|
||||||
dcmitype?: string;
|
|
||||||
xsi?: string;
|
|
||||||
type?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class HeaderAttributes extends XmlAttributeComponent<IHeaderAttributesProperties> {
|
|
||||||
protected xmlKeys = {
|
|
||||||
wpc: "xmlns:wpc",
|
|
||||||
mc: "xmlns:mc",
|
|
||||||
o: "xmlns:o",
|
|
||||||
r: "xmlns:r",
|
|
||||||
m: "xmlns:m",
|
|
||||||
v: "xmlns:v",
|
|
||||||
wp14: "xmlns:wp14",
|
|
||||||
wp: "xmlns:wp",
|
|
||||||
w10: "xmlns:w10",
|
|
||||||
w: "xmlns:w",
|
|
||||||
w14: "xmlns:w14",
|
|
||||||
w15: "xmlns:w15",
|
|
||||||
wpg: "xmlns:wpg",
|
|
||||||
wpi: "xmlns:wpi",
|
|
||||||
wne: "xmlns:wne",
|
|
||||||
wps: "xmlns:wps",
|
|
||||||
cp: "xmlns:cp",
|
|
||||||
dc: "xmlns:dc",
|
|
||||||
dcterms: "xmlns:dcterms",
|
|
||||||
dcmitype: "xmlns:dcmitype",
|
|
||||||
xsi: "xmlns:xsi",
|
|
||||||
type: "xsi:type",
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
// http://officeopenxml.com/WPheaders.php
|
|
||||||
import { IMediaData } from "file/media";
|
|
||||||
import { XmlComponent } from "file/xml-components";
|
|
||||||
import { Paragraph, PictureRun } from "../paragraph";
|
|
||||||
import { Table } from "../table";
|
|
||||||
import { HeaderAttributes } from "./header-attributes";
|
|
||||||
|
|
||||||
export class Header2 extends XmlComponent {
|
|
||||||
constructor() {
|
|
||||||
super("w:hdr");
|
|
||||||
this.root.push(
|
|
||||||
new HeaderAttributes({
|
|
||||||
wpc: "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
||||||
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
||||||
o: "urn:schemas-microsoft-com:office:office",
|
|
||||||
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
||||||
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
||||||
v: "urn:schemas-microsoft-com:vml",
|
|
||||||
wp14: "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
|
||||||
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
||||||
w10: "urn:schemas-microsoft-com:office:word",
|
|
||||||
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
||||||
w14: "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
||||||
w15: "http://schemas.microsoft.com/office/word/2012/wordml",
|
|
||||||
wpg: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
|
|
||||||
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
|
||||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
|
||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public addParagraph(paragraph: Paragraph): void {
|
|
||||||
this.root.push(paragraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
public createParagraph(text?: string): Paragraph {
|
|
||||||
const para = new Paragraph(text);
|
|
||||||
this.addParagraph(para);
|
|
||||||
return para;
|
|
||||||
}
|
|
||||||
|
|
||||||
public addTable(table: Table): void {
|
|
||||||
this.root.push(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
public createTable(rows: number, cols: number): Table {
|
|
||||||
const table = new Table(rows, cols);
|
|
||||||
this.addTable(table);
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
public addDrawing(imageData: IMediaData): void {
|
|
||||||
const paragraph = new Paragraph();
|
|
||||||
const run = new PictureRun(imageData);
|
|
||||||
paragraph.addRun(run);
|
|
||||||
|
|
||||||
this.root.push(paragraph);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from "./header";
|
|
Reference in New Issue
Block a user