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:
![Screenshot 2024-02-18 at 3 42 53 PM](https://private-user-images.githubusercontent.com/96314887/305745258-c6e1f742-cf87-444d-a662-6ea81aaad5a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTcyOTUsIm5iZiI6MTczOTE1Njk5NSwicGF0aCI6Ii85NjMxNDg4Ny8zMDU3NDUyNTgtYzZlMWY3NDItY2Y4Ny00NDRkLWE2NjItNmVhODFhYWFkNWEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAzMDk1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjNWQyZTQ2MmE3MWY3MTE3Y2I0ZDY5NDhmZWUwMTI1NDY2YTg4NDdlODlkYWE5ZjNlNTU2MGU4YTdmYmViYzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.OZTPo-8CL6LHveQ5NUcTJbnr5al3RPQO_kDFm7tmeT4)
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