{"action":"closed","issue":{"url":"https://api.github.com/repos/someatoms/jsPDF-AutoTable/issues/29","labels_url":"https://api.github.com/repos/someatoms/jsPDF-AutoTable/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/someatoms/jsPDF-AutoTable/issues/29/comments","events_url":"https://api.github.com/repos/someatoms/jsPDF-AutoTable/issues/29/events","html_url":"https://github.com/someatoms/jsPDF-AutoTable/issues/29","id":75002834,"number":29,"title":"Column width wrong when values contain new line characters","user":{"login":"GitMyCode","id":3288428,"avatar_url":"https://avatars.githubusercontent.com/u/3288428?v=3","gravatar_id":"","url":"https://api.github.com/users/GitMyCode","html_url":"https://github.com/GitMyCode","followers_url":"https://api.github.com/users/GitMyCode/followers","following_url":"https://api.github.com/users/GitMyCode/following{/other_user}","gists_url":"https://api.github.com/users/GitMyCode/gists{/gist_id}","starred_url":"https://api.github.com/users/GitMyCode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GitMyCode/subscriptions","organizations_url":"https://api.github.com/users/GitMyCode/orgs","repos_url":"https://api.github.com/users/GitMyCode/repos","events_url":"https://api.github.com/users/GitMyCode/events{/privacy}","received_events_url":"https://api.github.com/users/GitMyCode/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/someatoms/jsPDF-AutoTable/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/someatoms/jsPDF-AutoTable/labels/unlabel","name":"unlabel","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-10T21:11:38Z","updated_at":"2015-08-24T20:33:36Z","closed_at":"2015-08-24T20:33:36Z","body":"Hi!\r\nI wanted a column 'textarea' with breaklines. but the width of the column was computed on the all the char like it was on one line.\r\n\r\n![badwidth](https://cloud.githubusercontent.com/assets/3288428/7556236/c36e2a30-f736-11e4-9412-5e70a41e5875.PNG)\r\n\r\ni had to quick fix it with this code\r\n```javascript\r\n function getStringWidth(txt) {\r\n        var isBold = doc.internal.getFont().fontStyle === 'bold';\r\n\r\n        var textWithBreakLine = txt.split(\"\\n\");\r\n        if (textWithBreakLine.length > 1) {\r\n            var widest = 0;\r\n            textWithBreakLine.forEach(function(line) {\r\n                var lineWidth = doc.getStringUnitWidth(line) * doc.internal.getFontSize() + (isBold ? 5 : 0);\r\n                widest = (lineWidth > widest) ? lineWidth : widest;\r\n            });\r\n            return widest;\r\n        } else {\r\n            return doc.getStringUnitWidth(txt) * doc.internal.getFontSize() + (isBold ? 5 : 0);\r\n        }\r\n    }\r\n```\r\n\r\n\r\nThe result is this\r\n\r\n![whatiwant](https://cloud.githubusercontent.com/assets/3288428/7556244/0304570a-f737-11e4-8108-8361f937055c.PNG)\r\n\r\nI just wanted to mention it and i suppose it wouldn't be a problem with the feature of a custom column width  #20 \r\n\r\n\r\n\r\n<!---\r\n@huboard:{\"order\":29.0,\"milestone_order\":29,\"custom_state\":\"\"}\n-->\r\n"}}