Skip to content

Is there any way that we have the ability to copy the text form pdf, like the actual pdf documents. #3263

@PathanMansoorKhan

Description

@PathanMansoorKhan

const content = document.getElementById('download_section');
const options = {
margin: [10, 8, 12, 14], // Adjust margins as needed
filename: ${fileName}.pdf,
image: { type: 'JPEG', quality: 0.1 },
html2canvas: { scale: 2 },
jsPDF: {
unit: 'mm',
format: 'a4',
orientation: 'portrait',
compress: true,
},
};

if (data === 'download') {
  html2pdf()
    .from(content)
    .set(options)
    .toPdf()
    .get('pdf')
    .then((pdf: any) => {
      const totalPages = pdf.internal.getNumberOfPages();
      const pageWidth = pdf.internal.pageSize.getWidth();
      const pageHeight = pdf.internal.pageSize.getHeight();
      for (let i = 1; i <= totalPages; i++) {
        pdf.setPage(i);
        const pageNumberText = `Page ${i} of ${totalPages}`;
        pdf.setFontSize(10);
        pdf.text(pageNumberText, pageWidth / 2, pageHeight - 7, {
          align: 'center',
        });
      }
    })
    .save()
    .then(() => {
      this.isLoading = false;
    });
} else if (data === 'upload') {
  html2pdf()
    .from(content)
    .set(options)
    .toPdf()
    .get('pdf')
    .then((pdf: any) => {
      const totalPages = pdf.internal.getNumberOfPages();
      const pageWidth = pdf.internal.pageSize.getWidth();
      const pageHeight = pdf.internal.pageSize.getHeight();
      for (let i = 1; i <= totalPages; i++) {
        pdf.setPage(i);
        const pageNumberText = `Page ${i} of ${totalPages}`;
        pdf.setFontSize(10);
        pdf.text(pageNumberText, pageWidth / 2, pageHeight - 7, {
          align: 'center',
        });
      }
      return pdf.output('blob');
    })
    .outputPdf('blob')
    .then((pdfBlob: Blob) => {
      this.uploadEMRFile(pdfBlob, EMRfileName);
      this.isLoading = false;
    });
} else {
  html2pdf()
    .from(content)
    .set(options)
    .toPdf()
    .get('pdf')
    .then((pdf: any) => {
      const totalPages = pdf.internal.getNumberOfPages();
      const pageWidth = pdf.internal.pageSize.getWidth();
      const pageHeight = pdf.internal.pageSize.getHeight();
      for (let i = 1; i <= totalPages; i++) {
        pdf.setPage(i);
        const pageNumberText = `Page ${i} of ${totalPages}`;
        pdf.setFontSize(10);
        pdf.text(pageNumberText, pageWidth / 2, pageHeight - 7, {
          align: 'center',
        });
      }
      return pdf.output('blob');
    })
    .outputPdf('blob')
    .then((pdfBlob) => {
      const pdfUrl = URL.createObjectURL(pdfBlob);
      const printWindow = window.open(pdfUrl);
      if (printWindow) {
        printWindow.addEventListener('load', () => {
          printWindow.focus();
          printWindow.print();
        });
      }
      this.isLoading = false;
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions