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
Hello ! This question is quite important i'm stuck for a professionnal work.
How can I write several texts on the same page with a defined Y position ?
My goal is to create a table and then write the content of the columns on the same line.
Like this : column1 | column2 | column3
Easy you would say :
exporttypePDFTableLine={text: string; width: number}privatewriteLine=(content: PDFTableLine[])=>{letoffsetX=this.doc.page.margins.left;conststartY=this.doc.y;letmaxLineHeight=0;//checking what column will be the tallestfor(leti=0;i<content.length;i++){consttextHeight=this.doc.heightOfString(content[i].text,{width: content[i].width,});maxLineHeight=Math.max(maxLineHeight,textHeight);}//write all the content of columnsfor(leti=0;i<content.length;i++){this.doc.text(content[i].text,offsetX,startY,{width: content[i].width,})offsetX+=content[i].width;//set the offset so the next text will be displayed on the next column}//avoid overlap text with setting the next line below the tallest columnthis.doc.y=startY+maxLineHeight;this.writeLineSeparator();//basically create a line with stroke()}
It's working perfectly ! Unless... If the first text is quite long and pdfkit creates a page to write the rest of the text, then the others column will be displayed on the next page from the Y position from the top of the page. I want all my columns to starts on the same page even if the first text creates a new page. How can I achieve that ?
(Ps: the issue also exist in pdfkit-table package) that's why i'm creating my own class to build tables
pdfkit version: 0.15.0
Node version: v20.15.1
Operating System: Ubuntu linux
The text was updated successfully, but these errors were encountered:
Hello ! This question is quite important i'm stuck for a professionnal work.
How can I write several texts on the same page with a defined Y position ?
My goal is to create a table and then write the content of the columns on the same line.
Like this : column1 | column2 | column3
Easy you would say :
It's working perfectly ! Unless... If the first text is quite long and pdfkit creates a page to write the rest of the text, then the others column will be displayed on the next page from the Y position from the top of the page. I want all my columns to starts on the same page even if the first text creates a new page. How can I achieve that ?
(Ps: the issue also exist in pdfkit-table package) that's why i'm creating my own class to build tables
The text was updated successfully, but these errors were encountered: