Preview:
// Method to export help content to PDF
  exportToPDF(): void {
    const doc = new jsPDF();
    let y = 10;
    const pageHeight = doc.internal.pageSize.height;
    const margin = 10;

    this.helpContent.forEach(item => {
      if (y + 10 > pageHeight - margin) {
        doc.addPage();
        y = margin;
      }

      doc.setFontSize(14);
      doc.text(item.title, margin, y);
      y += 10;

      doc.setFontSize(12);

      const plainText = this.htmlToPlainText(item.content);
      const splitContent = doc.splitTextToSize(plainText, 180 - 2 * margin);

      splitContent.forEach((line: string) => {
        if (y + 7 > pageHeight - margin) {
          doc.addPage();
          y = margin;
        }
        doc.text(line, margin, y);
        y += 5;
      });

      y += 7; // Add space between sections
    });

    doc.save('help-guide.pdf');
  }

  // Method to convert HTML content to plain text
  htmlToPlainText(html: string): string {
    const doc = new DOMParser().parseFromString(html, 'text/html');
    return doc.body.textContent || '';
  }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter