From 1018ae6836e7f0c816ada310558a0b67a2ebc3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lionel=20Lask=C3=A9?= Date: Thu, 23 May 2024 22:13:40 +0200 Subject: [PATCH] Fix PDF generation in Story on Android/iOS --- CHANGELOG.md | 1 + activities/Story.activity/js/activity.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 056382470..a98e614c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Blank screen on iOS when opening a PDF #1618 - Journal instance pop up remain after launching a PDF or an external app #1619 - Welcome message not displayed in Write activity #1617 +- PDF generated by Story doesn't contain image on iOS/Android #969 ## [1.8.0] - 2024-04-10 ### Added diff --git a/activities/Story.activity/js/activity.js b/activities/Story.activity/js/activity.js index bf0ab3a68..0976a41df 100644 --- a/activities/Story.activity/js/activity.js +++ b/activities/Story.activity/js/activity.js @@ -317,11 +317,11 @@ var app = new Vue({ getUrlImg: function(img){ if (this.isConnected){ if (img.includes("lower")){ - return '../Abecedarium.activity/images/letters/'+ img.toLowerCase()[6] + '0.png'; + return document.location.href.substr(0, document.location.href.indexOf("/activities/"))+"/activities/Abecedarium.activity/images/letters/"+img.toLowerCase()[6]+"0.png"; } else if (img.includes("upper")){ - return '../Abecedarium.activity/images/letters/'+ img.toLowerCase()[6] + '1.png'; + return document.location.href.substr(0, document.location.href.indexOf("/activities/"))+"/activities/Abecedarium.activity/images/letters/"+img.toLowerCase()[6]+"1.png"; } else { - return '../Abecedarium.activity/images/database/'+ img + '.png'; + return document.location.href.substr(0, document.location.href.indexOf("/activities/"))+"/activities/Abecedarium.activity/images/database/"+img+".png"; } } else { if (img.includes("lower")){ @@ -340,7 +340,7 @@ var app = new Vue({ if (this.grid){ if (this.gridImageURL==null && document.getElementById("display-grid")!=null){ var ele = document.getElementById("display-grid"); - html2canvas(ele).then(function(canvas){ + html2canvas(ele, {allowTaint:true, useCORS:true}).then(function(canvas){ var img = canvas.toDataURL('image/png'); that.gridImageURL = img; }) @@ -480,7 +480,7 @@ var app = new Vue({ setTimeout(()=>{ if (document.getElementById("display-grid")!=null){ var ele = document.getElementById("display-grid"); - html2canvas(ele).then(function(canvas){ + html2canvas(ele, {allowTaint:true, useCORS:true}).then(function(canvas){ var img = canvas.toDataURL('image/png'); that.gridImageURL = img; }) @@ -573,7 +573,7 @@ var app = new Vue({ that.storeData(); if (document.getElementById("display-grid")!=null){ var ele = document.getElementById("display-grid"); - html2canvas(ele).then(function(canvas){ + html2canvas(ele, {allowTaint:true, useCORS:true}).then(function(canvas){ var img = canvas.toDataURL('image/png'); that.gridImageURL = img; }) @@ -701,7 +701,7 @@ var app = new Vue({ var doc = new jsPDF('p', 'mm' , '',true); function generateOnePdf(i) { - html2canvas(document.getElementById("display-single")).then(function(canvasImgs){ + html2canvas(document.getElementById("display-single"), {allowTaint:true, useCORS:true}).then(function(canvasImgs){ if (i