Add text frame documentation
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
> Easily generate .docx files with JS/TS. Works for Node and on the Browser. :100:
|
> Easily generate .docx files with JS/TS. Works for Node and on the Browser. :100:
|
||||||
|
|
||||||
- Simple, declarative API
|
- Simple, declarative API
|
||||||
- 50+ usage examples
|
- 60+ usage examples
|
||||||
- Battle tested, mature, 98%+ coverage
|
- Battle tested, mature, 98%+ coverage
|
||||||
|
|
||||||
[GitHub](https://github.com/dolanmiu/docx)
|
[GitHub](https://github.com/dolanmiu/docx)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* [Page Numbers](usage/page-numbers.md)
|
* [Page Numbers](usage/page-numbers.md)
|
||||||
* [Change Tracking](usage/change-tracking.md)
|
* [Change Tracking](usage/change-tracking.md)
|
||||||
* [Math](usage/math.md)
|
* [Math](usage/math.md)
|
||||||
|
* [Text Frames](usage/text-frames.md)
|
||||||
* Styling
|
* Styling
|
||||||
* [Styling with JS](usage/styling-with-js.md)
|
* [Styling with JS](usage/styling-with-js.md)
|
||||||
* [Styling with XML](usage/styling-with-xml.md)
|
* [Styling with XML](usage/styling-with-xml.md)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Bullet Points
|
# Bullet Points
|
||||||
|
|
||||||
|
!> Bullet Points requires an understanding of [Paragraphs](usage/paragraph.md).
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
To make a bullet point, simply make a paragraph into a bullet point:
|
To make a bullet point, simply make a paragraph into a bullet point:
|
||||||
|
@ -32,7 +32,7 @@ const paragraph = new Paragraph({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
After you create the paragraph, you must add the paragraph into the `document's section`. Learn more about `sections` here:
|
After you create the paragraph, you must add the paragraph into a `section`:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
doc.addSection({
|
doc.addSection({
|
||||||
@ -74,9 +74,11 @@ This is the list of options for a paragraph. A detailed explanation is below:
|
|||||||
| keepNext | `boolean` | Optional | |
|
| keepNext | `boolean` | Optional | |
|
||||||
| children | `(TextRun or PictureRun or Hyperlink)[]` | Optional | |
|
| children | `(TextRun or PictureRun or Hyperlink)[]` | Optional | |
|
||||||
| style | `string` | Optional | |
|
| style | `string` | Optional | |
|
||||||
| tabStop | `{ left?: ITabStopOptions; right?: ITabStopOptions; maxRight?: { leader: LeaderType; }; center?: ITabStopOptions }` | Optional | |
|
| [tabStop](usage/tab-stops) | `{ left?: ITabStopOptions; right?: ITabStopOptions; maxRight?: { leader: LeaderType; }; center?: ITabStopOptions }` | Optional | |
|
||||||
| bullet | `{ level: number }` | Optional | |
|
| [bullet](usage/bullet-points) | `{ level: number }` | Optional | |
|
||||||
| numbering | `{ num: ConcreteNumbering; level: number; custom?: boolean }` | Optional | |
|
| [numbering](usage/numbering) | `{ num: ConcreteNumbering; level: number; custom?: boolean }` | Optional | |
|
||||||
|
| [widowControl](#widow-control) | `boolean` | Optional | |
|
||||||
|
| [frame](usage/text-frames.md) | `IFrameOptions` | Optional | |
|
||||||
|
|
||||||
## Text
|
## Text
|
||||||
|
|
||||||
@ -157,6 +159,17 @@ const paragraph = new Paragraph({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Widow Control
|
||||||
|
|
||||||
|
Allow First/Last Line to Display on a Separate Page
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
text: "shading",
|
||||||
|
widowControl: true,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Spacing
|
## Spacing
|
||||||
|
|
||||||
Adding spacing between paragraphs
|
Adding spacing between paragraphs
|
||||||
@ -195,7 +208,7 @@ const paragraph = new Paragraph({
|
|||||||
|
|
||||||
## Styles
|
## Styles
|
||||||
|
|
||||||
To create styles, please refer to the styling Wiki: https://github.com/dolanmiu/docx/wiki/Styling
|
To create styles, please refer to the [styling documentation](usage/styling-with-js)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
69
docs/usage/text-frames.md
Normal file
69
docs/usage/text-frames.md
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# Text Frames
|
||||||
|
|
||||||
|
Also known as `Text Boxes`
|
||||||
|
|
||||||
|
!> Text Frames requires an understanding of [Paragraphs](usage/paragraph.md).
|
||||||
|
|
||||||
|
> 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.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
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,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
```
|
Reference in New Issue
Block a user