diff --git a/lang/en/pdfannotator.php b/lang/en/pdfannotator.php
index b27d831edc5cb01919dd73bc2d6c6b3d3960dffc..e237efc5466269e64bf4d85e206dde1204b53c70 100644
--- a/lang/en/pdfannotator.php
+++ b/lang/en/pdfannotator.php
@@ -109,6 +109,7 @@ $string['error:getAnnotation'] = 'An error has occured while getting the annotat
 $string['error:getAnnotations'] = 'An error has occured while getting all annotations.';
 $string['error:getComments'] = 'An error has occured while getting the comments.';
 $string['error:getQuestions'] = 'An error has occured while getting the questions for this page.';
+$string['error:printComments'] = 'Error with data from server.';
 $string['error:hideComment'] = "An error has occured while trying to hide the comment from participants' view.";
 $string['error:markasread'] = 'The item could not be marked as read.';
 $string['error:markasunread'] = 'The item could not be marked as unread.';
diff --git a/locallib.php b/locallib.php
index 71d344bf8be13a6bb14ac3059516b36e64d9589b..0bbd5bc3f4508fe535c6cbc0550fcca88f53799a 100644
--- a/locallib.php
+++ b/locallib.php
@@ -64,7 +64,7 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
     // Load and execute the javascript files.
     $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
     $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
-    $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00033"));
+    $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00034"));
     $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00005"));
 
     // Pass parameters from PHP to JavaScript.
@@ -167,7 +167,7 @@ function pdfannotator_extract_images($contentarr, $itemid, $context=null) {
 }
 
 function pdfannotator_split_content_image($content, $res, $itemid, $context=null) {
-
+    global $CFG;
     // Gets all files in the comment with id itemid.
     $fs = get_file_storage();
     $files = $fs->get_area_files($context->id, 'mod_pdfannotator', 'post', $itemid);
@@ -226,6 +226,15 @@ function pdfannotator_split_content_image($content, $res, $itemid, $context=null
             $data['filename'] = $tempinfo['filename'];
             $data['filepath'] = $tempinfo['filepath'];
             $data['filesize'] = $tempinfo['filesize'];
+            $data['imagestorage'] = 'intern';
+        } else if (!str_contains($CFG->wwwroot, $url[0])){
+            $data['imagestorage'] = 'extern';
+            $data['format'] =  $format[0];
+            $data['image'] = 'data:image/' . $format[0] . ";base64," . base64_encode(file_get_contents($url[0]));
+            // $data['image'] = $url[0];
+        } else {
+            $data['success'] = "error";
+            $data['message'] = "cannot load image";
         }
 
         preg_match('/height=[0-9]+/', $imgstr, $height);
diff --git a/shared/index.js b/shared/index.js
index 8e3a88b1866fe4c3ab5b489cf597221605ddbe4d..b37df0b71b9ed01969f5d6962ee927b9b1c4abbe 100644
--- a/shared/index.js
+++ b/shared/index.js
@@ -597,6 +597,11 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                     data: { "documentId": documentId, "action": 'getCommentsToPrint', sesskey: M.cfg.sesskey}
                     }).then(function(data){
                         return JSON.parse(data);
+                    }).catch(function(err) {
+                        notification.addNotification({
+                            message: M.util.get_string('error:printComments','pdfannotator'),
+                            type: "error"
+                        });
                     });
                 }
             },
@@ -850,12 +855,17 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                                         }
                                     }
                                     function printImage(data) {
-                                        // var url = data['image'];
-                                        // var imageElement = document.createElement("img");
-                                        // imageElement.src = url;
-                                        var url = data['image'];
-                                        var height = data['imageheight'] * 0.264583333333334; // Convert pixel into mm.
-
+                                        var url;
+                                        var image;
+                                        // if (data['imagestorage'] === 'extern') {
+                                        //     url = data['image'];
+                                        //     image = document.createElement("img");
+                                        //     image.setAttribute('crossOrigin', 'anonymous');
+                                        //     image.src = url;
+                                        // } else {
+                                            image = data['image'];
+                                            var height = data['imageheight'] * 0.264583333333334; // Convert pixel into mm.
+                                        // }
                                         // Reduce height and witdh if its size more than a4height.
                                         while ( height > (a4height-(2*contentTopBottomMargin) )) {
                                             height = height - (height*0.1);
@@ -868,7 +878,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                                             doc.addPage();
                                             count = contentTopBottomMargin;
                                         }
-                                        doc.addImage(url, data['format'], contentRightMargin, count, width, height); // image data, format, offset to the left, offset to the top, width, height
+                                        doc.addImage(image, data['format'], contentRightMargin, count, width, height); // image data, format, offset to the left, offset to the top, width, height
                                         count += (5 + height);
                                     }
                                     /**
@@ -1739,17 +1749,9 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                             
                             let newContent = editTextarea.value.trim();
                             let imgContents = editAreaEditable.querySelectorAll('img');
-                            let isEmptyContent = false;
-                            if(editAreaEditable.innerText.replace('/\n/g', '').trim() === '') {
-                                isEmptyContent = true;
-                            }
+                            let isEmptyContent = editAreaEditable.innerText.replace('/\n/g', '').trim() === '';
                             let defaultPTag = editAreaEditable.querySelector('p');
-                            if(defaultPTag) {
-                                // No text and no images in default p tag of editor.
-                                if (defaultPTag.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0 && editAreaEditable.childNodes.length === 0) {
-                                    isEmptyContent = true;
-                                }
-                            }
+                            isEmptyContent = (defaultPTag && defaultPTag.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0) && editAreaEditable.childNodes.length === 0;
                             if(isEmptyContent && imgContents.length === 0){
                                 // Should be more than one character, otherwise it should not be saved.
                                 notification.addNotification({
@@ -1915,21 +1917,17 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
                             button1.style.display = 'inline';
                             var button2 = document.getElementById('questionsOnThisPage'); // to be found in index template
                             button2.style.display = 'inline';
-                            let isEmptyContent = false;
-
+                            
                             commentForm.onsubmit = function (e) {
                                 document.querySelector('#commentSubmit').disabled = true;
                                 var commentVisibility= read_visibility_of_checkbox();
                                 var isquestion = 0; // this is a normal comment, so it is not a question
                                 var commentContentElements = document.querySelectorAll('#id_pdfannotator_contenteditable')[0];
                                 var imgContents = commentContentElements.querySelectorAll('img');
+
                                 var innerContent = commentContentElements.innerText.replace('/\n/g', '').trim();
                                 var temp = commentContentElements.querySelectorAll('p')[0];
-                                if(temp) {
-                                    if ((temp.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0) && innerContent === '') {
-                                        isEmptyContent = true;
-                                    }
-                                }
+                                let isEmptyContent = (temp && temp.innerText.replace('/\n/g', '').trim() === '' && imgContents.length === 0) && innerContent === '';
                                 if(isEmptyContent && imgContents.length === 0){
                                     //should be more than one character, otherwise it should not be saved.
                                     notification.addNotification({
diff --git a/version.php b/version.php
index b0dd6a6880ac0991ad11e46be8233be1ece9f3c2..3364f24d1ff45880b6b682ecc2d6ea4ad4df274a 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 $plugin->component = 'mod_pdfannotator';
-$plugin->version   = 2022110201;
+$plugin->version   = 2022110700;
 $plugin->release  = 'PDF Annotator v1.4 release 11';
 $plugin->requires  = 2021051700;
 $plugin->maturity  = MATURITY_STABLE;