{"action":"created","issue":{"url":"https://api.github.com/repos/evidenceprime/html-docx-js/issues/47","repository_url":"https://api.github.com/repos/evidenceprime/html-docx-js","labels_url":"https://api.github.com/repos/evidenceprime/html-docx-js/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/evidenceprime/html-docx-js/issues/47/comments","events_url":"https://api.github.com/repos/evidenceprime/html-docx-js/issues/47/events","html_url":"https://github.com/evidenceprime/html-docx-js/issues/47","id":202749124,"node_id":"MDU6SXNzdWUyMDI3NDkxMjQ=","number":47,"title":"convertImagesToBase64","user":{"login":"stritti","id":184547,"node_id":"MDQ6VXNlcjE4NDU0Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/184547?v=4","gravatar_id":"","url":"https://api.github.com/users/stritti","html_url":"https://github.com/stritti","followers_url":"https://api.github.com/users/stritti/followers","following_url":"https://api.github.com/users/stritti/following{/other_user}","gists_url":"https://api.github.com/users/stritti/gists{/gist_id}","starred_url":"https://api.github.com/users/stritti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stritti/subscriptions","organizations_url":"https://api.github.com/users/stritti/orgs","repos_url":"https://api.github.com/users/stritti/repos","events_url":"https://api.github.com/users/stritti/events{/privacy}","received_events_url":"https://api.github.com/users/stritti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-24T08:02:27Z","updated_at":"2018-11-16T07:49:19Z","closed_at":null,"author_association":"NONE","body":"\r\nTo support images, which are scaled by css or attribute, the `canvas` should have the `naturalWidth`/`naturalHeight` not to be cropped in the word document:\r\n\r\n```javascript\r\nfunction convertImagesToBase64 (element) {\r\n\r\n  contentDocument = tinymce.get('content').getDoc();\r\n  var regularImages = contentDocument.querySelectorAll(\"img\");\r\n  var canvas = document.createElement('canvas');\r\n  var ctx = canvas.getContext('2d');\r\n  [].forEach.call(regularImages, function (imgElement) {\r\n\t// preparing canvas for drawing\r\n\tctx.clearRect(0, 0, canvas.width, canvas.height);\r\n// change here start\r\n\tcanvas.width = imgElement.naturalWidth;\r\n\tcanvas.height = imgElement.naturalHeight;\r\n//change here end\r\n\tctx.drawImage(imgElement, 0, 0);\r\n\t// by default toDataURL() produces png image, but you can also export to jpeg\r\n\t// checkout function's documentation for more details\r\n\tvar dataURL = canvas.toDataURL();\r\n\timgElement.setAttribute('src', dataURL);\r\n  })\r\n  canvas.remove();\r\n}\r\n```\r\n\r\nsee: https://github.com/evidenceprime/html-docx-js/blob/master/test/sample.html"},"comment":{"url":"https://api.github.com/repos/evidenceprime/html-docx-js/issues/comments/439309824","html_url":"https://github.com/evidenceprime/html-docx-js/issues/47#issuecomment-439309824","issue_url":"https://api.github.com/repos/evidenceprime/html-docx-js/issues/47","id":439309824,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTMwOTgyNA==","user":{"login":"tcgumus","id":2714346,"node_id":"MDQ6VXNlcjI3MTQzNDY=","avatar_url":"https://avatars1.githubusercontent.com/u/2714346?v=4","gravatar_id":"","url":"https://api.github.com/users/tcgumus","html_url":"https://github.com/tcgumus","followers_url":"https://api.github.com/users/tcgumus/followers","following_url":"https://api.github.com/users/tcgumus/following{/other_user}","gists_url":"https://api.github.com/users/tcgumus/gists{/gist_id}","starred_url":"https://api.github.com/users/tcgumus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcgumus/subscriptions","organizations_url":"https://api.github.com/users/tcgumus/orgs","repos_url":"https://api.github.com/users/tcgumus/repos","events_url":"https://api.github.com/users/tcgumus/events{/privacy}","received_events_url":"https://api.github.com/users/tcgumus/received_events","type":"User","site_admin":false},"created_at":"2018-11-16T07:49:19Z","updated_at":"2018-11-16T07:49:19Z","author_association":"NONE","body":"Thank you. You are a rare kind of man."}}
{"actor":{"display_login":"tcgumus"}}