score:2

Accepted answer

kendo doesn't support rendering/saving pdf outside dom: https://github.com/telerik/kendo-react/issues/307#issuecomment-521232445

score:-1

the first argument to savepdf is a dom element and not a jsx element. this will work.

class app extends component {
  exportpdf() {
        // todo: fetch data from backend
        // todo: move content generator to different function
        // const element = <h2>teeeeest</h2>
        const element = document.getelementbyid('test')

        savepdf(element, {
            papersize: 'a4',
            filename: 'report.pdf',
            margin: { top: '2cm', left: '1.5cm', right: '1.5cm', bottom: '2cm' },
            scale: 0.8,
            keeptogether: '.card',
        });
    }

  render() {
    return (
      <div>
        <h1 id='hello'>hello kendo</h1>
        <h2 id='test' style={{display: 'none'}}>teeeest</h2>
        <navlink classname="pr-1" to="#" onclick={() => this.exportpdf()}>download pdf</navlink>
      </div>
    );
  }
}

here's the link to the documentation for savepdf method - https://www.telerik.com/kendo-react-ui/components/pdfprocessing/api/savepdf/


Related Query

More Query from same tag