I am writing some content in bullet points in HTML and then using swiper.js library ( https://swiperjs.com/demos/255-effect-cards/core) to display them as sliders. I am giving a download button to the slider and want the user to download all those sliders at once which are written inside HTML divs
Can you help me with how can make it work?
- User sees slider
- The user clicks on the download
- It should convert all N slides into image format files(png/jpeg) and download each image to the user's device.
code for js slider which has multiple divs and content inside each div
<div class="swiper mySwiper" >
<div class="swiper-wrapper">
<div class="swiper-slide">
<h3 #screen>{{summary[0]}}</h3>
</div>
<div class="swiper-slide" >
<h3 #screen>{{summary[1]}}</h3>
</div>
<div class="swiper-slide">
<h3>{{summary[2]}}</h3>
</div>
<div class="swiper-slide">
<h3>{{summary[3]}}</h3>
</div>
<div *ngIf="summary[4] != null" class="swiper-slide">
<h3>{{summary[4]}}</h3>
</div>
</div>
</div>
converting each div into an image
<div id="download" class="main" *ngIf="image">
<img #canvas>
<a #downloadLink></a>
</div>
@ViewChild('screen') screen: ElementRef;
@ViewChild('canvas') canvas: ElementRef;
@ViewChild('downloadLink') downloadLink: ElementRef;
when user clicks on the button it should download all of the slides in one go
html2canvas(this.screen.nativeElement).then((canvas: any) => {
this.canvas.nativeElement.src = canvas.toDataURL();
this.downloadLink.nativeElement.href = canvas.toDataURL('image/png');
this.downloadLink.nativeElement.download = 'summary.png';
this.downloadLink.nativeElement.click();
});