mirror of
https://github.com/dolanmiu/docx.git
synced 2026-11-30 16:47:55 +01:00
* feat: Migrate to new component authoring # Conflicts: # src/file/table-of-contents/table-of-contents.ts # Conflicts: # src/file/content-types/content-types.ts # src/file/paragraph/properties.ts # src/file/table/table-properties/table-properties.ts # Conflicts: # src/file/document/body/section-properties/section-properties.ts # src/file/paragraph/run/run.ts # src/file/table-of-contents/table-of-contents.ts # src/file/table/grid.ts # src/file/table/table-cell/table-cell-properties.ts # src/file/table/table.ts * Clarify public api * Add docs * Fix tests and linting * Fix readonly array * Fix spelling * Update ToC docs * Update WPS to use BuilderElement * Migrate components to use Builder element Add ESLint rules * Comment out the template demos * Ignore demo 90 until we fix schema validation * Disable demo validation * Disable doc * Disable validation for now --------- Co-authored-by: Dolan Miu <>
1.8 KiB
1.8 KiB
Text Frames
Similar to
Text Boxes!
!> Text Frames requires an understanding of Paragraphs.
Text frames are paragraphs of text in a document which are positioned in a separate region or frame in the document, and can be positioned with a specific size and position relative to non-frame paragraphs in the current document.
Intro
To make a Text Frame, simply add the frame property on a paragraph. Borders can be applied to frame simply by adding the border attribute.
new Paragraph({
frame: {
position: {
x: 1000,
y: 3000,
},
width: 4000,
height: 1000,
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
alignment: {
x: HorizontalPositionAlign.CENTER,
y: VerticalPositionAlign.TOP,
},
},
border: {
top: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
bottom: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
left: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
right: {
color: "auto",
space: 1,
value: "single",
size: 6,
},
},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
text: "\tGithub is the best",
bold: true,
}),
],
});
Demo
Source: https://github.com/dolanmiu/docx/blob/master/demo/61-text-frame.ts