提问人:Maxhirez 提问时间:8/16/2023 更新时间:8/16/2023 访问量:42
JSPDF AutoTable:在 didParseCell 中保留用户输入 TextArea 的换行符
JSPDF AutoTable: Preserve line breaks from user-entry TextArea in didParseCell
问:
我在 GitHub 上类似问题 #807 的末尾解决了这个问题,但我希望在这里得到更快的响应。
我正在 JS 中为一个单页应用程序创建一个动态表,其中一半的表内容来自 JSON,用户输入另一半。每行的最后一列是 a for notes。我在事件中使用了这样的东西:textarea
didParseText
if(data.column.index==3){
let cid = "#textarea-id-prefix"+data.row.index.toString();
try{
let cResult=document.querySelector(cid).value;
data.cell.text=cResult;
}
catch{er){console.log("No notes.")}
} ```
This however doesn’t pass the \n into the PDF as a line break, only as extra line spaces. Adding a `.replaceAll(“\n”,”<br/>”)` to cResult only inserts the `<br/>` characters (even using a regex for line breaks.)
Is there a better way to get the user entry out of the text area, or does someone have a trick for preserving the line breaks for readability in the generated PDF?
Thanks!
答: 暂无答案
评论