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
I am trying to export the PDF I created and it prints the pages 2 times
This is my code in React with Typescript:
import React, { useEffect, useRef } from 'react'
import Templ from './Template'
import { Form, Template } from '@pdfme/ui'
import { generate } from '@pdfme/generator'
import fileDownload from 'js-file-download'
const ContractTemplate = ({data}) => {
const designerRef = useRef<Form>()
//Download PDF Template with the Inputs values <<<<============================= This is the Generator Method ❗❗
const handleDownloadPdf = () => {
generate({
template:designerRef.current.getTemplate(),
inputs:designerRef.current.getInputs()
})
.then((pdf) => {
fileDownload(new Blob([pdf.buffer], { type: 'application/pdf' }), data.title+'.pdf')
})
}
useEffect(()=>{
if(data && data.template) {
//Prepare Editor values
const template = data.template as Template
const domContainer = document.getElementById('pdf-editor')
const inputs = template.schemas.map(schema => {
const input = {}
Object.keys(schema).forEach(key => {
input[key] = schema[key].type==='text' ? '' : template.sampledata[0][key]
})
return input
})
//Generate PDFME Form
designerRef.current = new Form({ domContainer, template, inputs })
}
//Destroy when exit
return () => {
if(designerRef.current)
designerRef.current.destroy()
}
}, [])
return <React.Fragment>
<Templ {...{data, handleDownloadPdf}}/>
</React.Fragment>
}
And this is the JSON data that I pass in the Generator Method : The basePdf var of the Template Object is a public URL of the Firebase server
You can open the url to check
What am I doing wrong? why does it throw me duplicate pages?
It seems that it first uses the pages with edited values and then puts them back without the edited values.
The text was updated successfully, but these errors were encountered:
I am trying to export the PDF I created and it prints the pages 2 times
This is my code in React with Typescript:
And this is the JSON data that I pass in the Generator Method :
The basePdf var of the Template Object is a public URL of the Firebase server
You can open the url to check
And this is the result:
What am I doing wrong? why does it throw me duplicate pages?
It seems that it first uses the pages with edited values and then puts them back without the edited values.
The text was updated successfully, but these errors were encountered: