You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library wraps around the [PptxGenJS](https://github.com/gitbrent/PptxGenJS) to generate shapes from scratch. It is possible to use the `pptxGenJS` wrapper to generate shapes on a slide.
587
+
588
+
Here's an example of how to use `pptxGenJS` to add a text shape to a slide:
589
+
```ts
590
+
pres.addSlide('empty', 1, (slide) => {
591
+
// Use pptxgenjs to add text from scratch:
592
+
slide.generate((pptxGenJSSlide) => {
593
+
pptxGenJSSlide.addText('Test 1', {
594
+
x: 1,
595
+
y: 1,
596
+
h: 5,
597
+
w: 10,
598
+
color: '363636',
599
+
});
600
+
}, 'custom object name');
601
+
});
602
+
```
603
+
604
+
You can as well create charts with `pptxGenJS`:
605
+
606
+
```ts
607
+
608
+
const dataChartAreaLine = [
609
+
{
610
+
name: 'Actual Sales',
611
+
labels: ['Jan', 'Feb', 'Mar'],
612
+
values: [1500, 4600, 5156],
613
+
},
614
+
{
615
+
name: 'Projected Sales',
616
+
labels: ['Jan', 'Feb', 'Mar'],
617
+
values: [1000, 2600, 3456],
618
+
},
619
+
];
620
+
621
+
pres.addSlide('empty', 1, (slide) => {
622
+
// Use pptxgenjs to add generated contents from scratch:
You can use the following functions to generate shapes with `pptxGenJS`:
635
+
* addChart
636
+
* addImage
637
+
* addShape
638
+
* addTable
639
+
* addText
640
+
641
+
582
642
## Remove elements from a slide
583
643
584
644
You can as well remove elements from slides.
@@ -596,28 +656,18 @@ pres
596
656
});
597
657
```
598
658
599
-
## 🔗 Hyperlink Management
600
-
601
-
PowerPoint presentations often use hyperlinks to connect to external websites or internal slides. The PPTX Automizer provides simple and powerful functions to manage hyperlinks in your presentations.
602
-
603
-
### Hyperlink Helper Functions
659
+
## Hyperlink Management
604
660
605
-
Three core functions are available for all your hyperlink needs:
661
+
PowerPoint presentations often use hyperlinks to connect to external websites or internal slides. The `pptx-automizer` provides simple and powerful functions to manage hyperlinks in your presentations.
606
662
607
-
| Function | Description |
608
-
|----------|-------------|
609
-
|`addHyperlink`| Add a new hyperlink to an element |
663
+
### Add Hyperlinks to existing shapes
610
664
611
-
612
-
### Adding Hyperlinks
613
-
614
-
You can add hyperlinks to text elements using the `addHyperlink` helper function. The function accepts either a URL string for external links or a slide number for internal slide links:
665
+
You can add hyperlinks to template text shapes using the `addHyperlink` helper function. The function accepts either a URL string for external links or a slide number for internal slide links:
The `addHyperlink` function will automatically detect whether the target is an external URL or an internal slide number and set up the appropriate relationship type and attributes.
628
678
679
+
### Create a new hyperlinked text shape with pptxGenJS
680
+
681
+
It is also possible to create a new hyperlink from scratch with the `pptxGenJS` wrapper. This is useful if you want to add hyperlinks to shapes that are not part of the template.
682
+
683
+
```ts
684
+
// Generate a new text shape pointing to an external site
685
+
slide.generate((pptxGenJSSlide) => {
686
+
pptxGenJSSlide.addText(`External Link`, {
687
+
hyperlink: { url: 'https://github.com' },
688
+
x: 1,
689
+
y: 1,
690
+
w: 2.5,
691
+
h: 0.5,
692
+
fontSize: 12,
693
+
});
694
+
});
695
+
696
+
// Or generate an internal hyperlink
697
+
slide.generate((pptxGenJSSlide) => {
698
+
pptxGenJSSlide.addText(`Go to slide 3`, {
699
+
hyperlink: { slide: 3 },
700
+
x: 1,
701
+
y: 1,
702
+
w: 2.5,
703
+
h: 0.5,
704
+
fontSize: 12,
705
+
});
706
+
});
707
+
```
708
+
629
709
# Tipps and Tricks
630
710
631
711
## Loop through the slides of a presentation
@@ -913,6 +993,7 @@ Take a look into [**tests**-directory](https://github.com/singerla/pptx-automize
If you encounter problems when opening a `.pptx`-file modified by this library, you might worry about PowerPoint not giving any details about the error. It can be hard to find the cause, but there are some things you can check:
917
998
918
999
-**Broken relation**: There are still unsupported shape types and `pptx-automizer` wil not copy required relations of those. You can inflate `.pptx`-output and check `ppt/slides/_rels/slide[#].xml.rels`-files to find possible missing files.
@@ -921,7 +1002,7 @@ If you encounter problems when opening a `.pptx`-file modified by this library,
921
1002
-**Proprietary/Binary contents** (e.g. ThinkCell): Walk through all slides, slideMasters and slideLayouts and seek for hidden Objects. Hit `ALT+F10` to toggle the sidebar.
922
1003
-**Chart datasheet won't open** If you encounter an error message on opening a chart's datasheet, please make sure that the data table (blue bordered rectangle in worksheet view) of your template starts at cell A:1. If not, open worksheet in Excel mode and edit the table size in the table draft tab.
923
1004
924
-
If none of these could help, please don't hesitate to [talk about it](https://github.com/singerla/pptx-automizer/issues/new).
1005
+
If none of these could help, please don't hesitate to [talk about it](https://github.com/singerla/pptx-automizer/issues/new).
0 commit comments