Styling bug when generating table #3147
Unanswered
MarvingMoreton
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am using html2canvas with jsPDF in my next js app. However, it seems like I am having an error specifically on the table part of my generation (which is an invoice), as you can see on the screenshot attached:
What is weird is that, it used to work, and the fact that it's not working anymore on the table part is very strange to me...
Here's my generatePDF function:
` const generatePDF = () => {
const input = document.getElementById('invoice')
if (input) {
html2canvas(input, {
scale: 2,
useCORS: true,
logging: true,
width: input.offsetWidth,
height: input.offsetHeight
})
.then((canvas) => {
// Pixels per millimeter (A4 size is 210mm x 297mm)
const imgData = canvas.toDataURL('image/png')
const pdf = new jsPDF('p', 'mm', 'a4')
const pdfWidth = pdf.internal.pageSize.getWidth()
const pdfHeight = pdf.internal.pageSize.getHeight()
const canvasWidth = canvas.width
const canvasHeight = canvas.height
const ratio = pdfWidth / canvasWidth
const imgWidth = canvasWidth * ratio
const imgHeight = canvasHeight * ratio
}`
And the section that is currently bugging:
` {isFormEmpty(details) ? (
// Render skeleton or placeholder if form is empty
) : (
{/* TABLE HERE */}
{i('itemsSection')}
{i('qty')}
{i('itemRate')}
{i('amount')}
I have tried:
Thanks in advance for the help!
Behavior visible live on: https://freel.ca/tools/free-invoice-generator
Beta Was this translation helpful? Give feedback.
All reactions