2.20.1 • Published 8 months ago

react-pptx v2.20.1

Weekly downloads
72
License
MIT
Repository
github
Last release
8 months ago

react-pptx

npm

React wrapper for PptxGenJS. Works both in browser and node. Try at https://wyozi.github.io/react-pptx/

import {
  Presentation, Slide, Text,
  Shape, Image, render
} from "react-pptx";
import fs from "fs";

render(
  <Presentation>
    <Slide>
      <Text style={{
        x: 3, y: 1, w: 3, h: 0.5,
        fontSize: 32
      }}>
        Hello there!
      </Text>
      <Shape
        type="rect"
        style={{
          x: 3, y: 1.55, w: 3, h: 0.1,
          backgroundColor: "#FF0000"
        }}
      />
    </Slide>
    <Slide>
      <Image
        src={{
          kind: "path",
          path: "http://www.fillmurray.com/460/300"
        }}
        style={{
          x: "10%", y: "10%", w: "80%", h: "80%"
        }}
      />
    </Slide>
  </Presentation>
).then(buffer => {
  fs.writeFile("presentation.pptx", buffer);
});

Api

ReactPPTX.render(<presentation>): Promise<Buffer>

Asynchronously renders given presentation JSX.

<Presentation>

Wraps the whole presentation.

Props

nametypedefault valuedescription
layout"16x9", "16x10", "4x3", or "wide""16x9"Slide size

<Slide>

Represents each slide in the presentation.

Props

nametypedefault valuedescription
hiddenbooleanfalseWhether this slide is hidden during presenting
style.backgroundColorcolorSlide background color
style.backgroundImage{kind: "path", path: ""} \| {kind: "data", data: ""}Background image url

<Text>

Text layer

Props

nametype default valuedescription
style.xnumber (inches) or string (percentage)Absolute x coordinate
style.ynumber (inches) or string (percentage)Absolute y coordinate
style.wnumber (inches) or string (percentage)Absolute width
style.hnumber (inches) or string (percentage)Absolute height
style.colorcolorText color
style.fontFacestringArialFont family. Try to stick to web-safe fonts
style.fontSizenumber (points)18Font size. Defined in points (96 dpi by default)
style.boldbooleanfalseWhether text is bold or not
style.italicbooleanfalseWhether text is italic or not
style.underlinebooleanfalseWhether text is underlined or not
style.subscriptbooleanfalseWhether text is subscript or not
style.superscriptbooleanfalseWhether text is superscript or not
style.strikebooleanfalseWhether text has a strikeout or not
style.insetbooleanfalseWhether text is inset or not
style.align"left" or "center" or "right"undefinedHorizontal text alignment within the text box
style.verticalAlign"top" or "middle" or "bottom"undefinedVertical text alignment within the text box
style.paraSpaceAfternumber (points)Paragraph spacing after the text
style.paraSpaceBeforenumber (points)Paragraph spacing before the text
style.charSpacingnumber (points)The amount of spacing between characters, between 1-256
style.lineSpacingnumber (points)Space between each line
style.marginnumber (points) or [number, number, number, number]Similar to CSS padding, 0-99
style.rotateintegerDegrees of text rotation, between 0-360
rtlModebooleanfalseWhether text is displayed in right-to-left or not
langstringen-USSetting for language, useful for non-English fonts

To see examples of the text formatting, see the underlying PptxGenJS documentation.

<Text.Link>

Link to somewhere. Only usable inside <Text>. You must specify either url or slide.

<Text.Bullet>

Bullet or numbered list item. Only usable inside <Text>.

nametype default valuedescription
type"bullet" or "number""bullet"Whether to use a bulleted list or numbered list
characterCodestringundefinedBullet character code (unicode)
indentnumber27Indentation (space between bullet and text) (points)
numberTypestringundefinedThe numbering type to use (Number type, see below)
numberStartAtnumberundefinedNumber bullets start at
rtlModebooleanfalseWhether text is displayed in right-to-left or not
langstringen-USSetting for language, useful for non-English fonts

To find out how these look, easiest to just Google .

  • 'alphaLcParenBoth'
  • 'alphaLcParenR'
  • 'alphaLcPeriod'
  • 'alphaUcParenBoth'
  • 'alphaUcParenR'
  • 'alphaUcPeriod'
  • 'arabicParenBoth'
  • 'arabicParenR'
  • 'arabicPeriod'
  • 'arabicPlain'
  • 'romanLcParenBoth'
  • 'romanLcParenR'
  • 'romanLcPeriod'
  • 'romanUcParenBoth'
  • 'romanUcParenR'
  • 'romanUcPeriod'

Props

nametype default valuedescription
urlstringURL to open
slidenumberSlide to open
tooltipstringTooltip on hover
rtlModebooleanfalseWhether text is displayed in right-to-left or not
langstringen-USSetting for language, useful for non-English fonts

<Image>

Image layer. Images are automatically fetched and embedded into the .pptx files during the rendering phase.

Supports png, jpg, svg, gif and animated gif.

Props

nametypedefault valuedescription
src{kind: "path", path: ""} \| {kind: "data", data: ""}Image URL
style.xnumber (inches) or string (percentage)Absolute x coordinate
style.ynumber (inches) or string (percentage)Absolute y coordinate
style.wnumber (inches) or string (percentage)Absolute width
style.hnumber (inches) or string (percentage)Absolute height

<Shape>

Shape layer.

Props

nametypedefault valuedescription
typeshape typesShape type
style.xnumber (inches) or string (percentage)Absolute x coordinate
style.ynumber (inches) or string (percentage)Absolute y coordinate
style.wnumber (inches) or string (percentage)Absolute width
style.hnumber (inches) or string (percentage)Absolute height
style.backgroundColorcomplex colorShape background color

To find out how these look, easiest to just Google.

  • accentBorderCallout1
  • accentBorderCallout2
  • accentBorderCallout3
  • accentCallout1
  • accentCallout2
  • accentCallout3
  • actionButtonBackPrevious
  • actionButtonBeginning
  • actionButtonBlank
  • actionButtonDocument
  • actionButtonEnd
  • actionButtonForwardNext
  • actionButtonHelp
  • actionButtonHome
  • actionButtonInformation
  • actionButtonMovie
  • actionButtonReturn
  • actionButtonSound
  • arc
  • bentArrow
  • bentUpArrow
  • bevel
  • blockArc
  • borderCallout1
  • borderCallout2
  • borderCallout3
  • bracePair
  • bracketPair
  • callout1
  • callout2
  • callout3
  • can
  • chartPlus
  • chartStar
  • chartX
  • chevron
  • chord
  • circularArrow
  • cloud
  • cloudCallout
  • corner
  • cornerTabs
  • cube
  • curvedDownArrow
  • curvedLeftArrow
  • curvedRightArrow
  • curvedUpArrow
  • decagon
  • diagStripe
  • diamond
  • dodecagon
  • donut
  • doubleWave
  • downArrow
  • downArrowCallout
  • ellipse
  • ellipseRibbon
  • ellipseRibbon2
  • flowChartAlternateProcess
  • flowChartCollate
  • flowChartConnector
  • flowChartDecision
  • flowChartDelay
  • flowChartDisplay
  • flowChartDocument
  • flowChartExtract
  • flowChartInputOutput
  • flowChartInternalStorage
  • flowChartMagneticDisk
  • flowChartMagneticDrum
  • flowChartMagneticTape
  • flowChartManualInput
  • flowChartManualOperation
  • flowChartMerge
  • flowChartMultidocument
  • flowChartOfflineStorage
  • flowChartOffpageConnector
  • flowChartOnlineStorage
  • flowChartOr
  • flowChartPredefinedProces'flowChartPredefinedProcess',
  • flowChartPreparation
  • flowChartProcess
  • flowChartPunchedCard
  • flowChartPunchedTape
  • flowChartSort
  • flowChartSummingJunction
  • flowChartTerminator
  • folderCorner
  • frame
  • funnel
  • gear6
  • gear9
  • halfFrame
  • heart
  • heptagon
  • hexagon
  • homePlate
  • horizontalScroll
  • irregularSeal1
  • irregularSeal2
  • leftArrow
  • leftArrowCallout
  • leftBrace
  • leftBracket
  • leftCircularArrow
  • leftRightArrow
  • leftRightArrowCallout
  • leftRightCircularArrow
  • leftRightRibbon
  • leftRightUpArrow
  • leftUpArrow
  • lightningBolt
  • line
  • lineInv
  • mathDivide
  • mathEqual
  • mathMinus
  • mathMultiply
  • mathNotEqual
  • mathPlus
  • moon
  • nonIsoscelesTrapezoid
  • noSmoking
  • notchedRightArrow
  • octagon
  • parallelogram
  • pentagon
  • pie
  • pieWedge
  • plaque
  • plaqueTabs
  • plus
  • quadArrow
  • quadArrowCallout
  • rect
  • ribbon
  • ribbon2
  • rightArrow
  • rightArrowCallout
  • rightBrace
  • rightBracket
  • round1Rect
  • round2DiagRect
  • round2SameRect
  • roundRect
  • rtTriangle
  • smileyFace
  • snip1Rect
  • snip2DiagRect
  • snip2SameRect
  • snipRoundRect
  • squareTabs
  • star10
  • star12
  • star16
  • star24
  • star32
  • star4
  • star5
  • star6
  • star7
  • star8
  • stripedRightArrow
  • sun
  • swooshArrow
  • teardrop
  • trapezoid
  • triangle
  • upArrow
  • upArrowCallout
  • upDownArrow
  • upDownArrowCallout
  • uturnArrow
  • verticalScroll
  • wave
  • wedgeEllipseCallout
  • wedgeRectCallout
  • wedgeRoundRectCallout

Shapes support complex colors for the backgroundColor property. These are the currently supported complex color types:

  • Translucent colors (e.g. rgba(255, 127, 0, 0.5) for orange at 50% opacity)

<Line>

Line layer. Internally uses <Shape> but is separate for convinience.

Props

nametypedefault valuedescription
x1number (inches) or string (percentage)Line start x coordinate
y1number (inches) or string (percentage)Line start y coordinate
x2number (inches) or string (percentage)Line end x coordinate
y2number (inches) or string (percentage)Line end y coordinate
style.colorhex colorLine color
style.widthnumber (inches) or string (percentage)Line width

Credits / Shoutouts

2.19.0

9 months ago

2.19.1

9 months ago

2.20.0

8 months ago

2.20.1

8 months ago

2.18.0

1 year ago

2.17.0

2 years ago

2.17.1

2 years ago

2.16.1

2 years ago

2.16.2

2 years ago

2.15.0

2 years ago

2.16.0

2 years ago

2.14.1

2 years ago

2.14.0

3 years ago

2.12.0

3 years ago

2.13.0

3 years ago

2.12.1

3 years ago

2.11.0

3 years ago

2.10.0

3 years ago

2.9.0

3 years ago

2.8.0

3 years ago

2.7.0

3 years ago

2.6.0

3 years ago

2.5.0

4 years ago

2.4.2

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago