Print image in a tab

Home Forums General discussion Print image in a tab

Viewing 9 reply threads
  • Author
    Posts
    • #23401
      HYM
      Participant

        Hi Alexander, when I print a tab where it contains an image inside a multi-line field the image is not printed any idea how to solve this issue?

      • #23421
        Alexander Bautz
        Keymaster

          Hi,
          Are you using Insert > From Computer and adding the image to Site Assets?

          I’m working on an updated version of the print current tab code – can you try adding this snippet to your Custom JS and see if it makes any difference?

          Alexander

          • This reply was modified 5 years, 11 months ago by Alexander Bautz. Reason: Added missing link to code snippet
        • #23435
          HYM
          Participant

            i tried both options to insert picture from SharePoint/Computer and still is not working.
            which snippet should i add to my custom js, you didn’t send it.

          • #23438
            Alexander Bautz
            Keymaster

              Sorry, I forgot the link – I have updated the post and added it.

              Alexander

            • #23440
              HYM
              Participant

                it didn’t work on explorer and chrome — error: spjs_path is undefined.
                DFFS version: 4.4.3.58 — 4.46 —- 1.328

              • #23442
                Alexander Bautz
                Keymaster

                  OK, the variable spjs_path is from the DFFS_loader.html – have you installed DFFS with the “local installer” or in another way?

                  If you didn’t use the local installer you can add a variable to the custom js like this:

                  var spjs_path = "/PathToTheSiteWhereSPJSisLocated/SPJS/DFFS/";

                  Change PathToTheSiteWhereSPJSisLocated to the actual path to your site.

                  Alexander

                • #23444
                  HYM
                  Participant

                    it worked but i lost part of my configuration print header and footer.

                  • #23446
                    Alexander Bautz
                    Keymaster

                      I’m glad it worked – the snippet I linked to was “work in progress” – try this one as it includes the custom header and footer:

                      spjs.dffs.printCurrentTab = function () {
                          if (spjs.dffs.data.selectedTab === "") {
                              return;
                          }
                          jQuery("body").append("<iframe id='dffs_print_form'></iframe>");
                          var iframe = jQuery('#dffs_print_form'), path, b = [];
                          // Add default SP style sheet
                          if (_spPageContextInfo.webUIVersion >= 15) {
                              path = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/" + _spPageContextInfo.currentLanguage + "/styles/themable/";
                              b.push("<link rel='stylesheet' type='text/css' href='" + path + "corev" + _spPageContextInfo.webUIVersion + ".css' />");
                          } else {
                              path = _spPageContextInfo.webAbsoluteUrl + "/_layouts/" + _spPageContextInfo.currentLanguage + "/styles/";
                              b.push("<link rel='stylesheet' type='text/css' href='" + path + "corev4.css' />");
                          }
                          // Add default DFFS style sheet
                          b.push("<link rel='stylesheet' type='text/css' href='" + spjs_path + "css/dffs_frontend.css' />");
                          // Add DFFS Custom CSS
                          b.push("<style type='text/css'>" + unescape(spjs.dffs.data.dffsDataObj.customCSS) + "</style>");
                          // Load files included above Custom CSS
                          jQuery.each(spjs.dffs.data.requireCSSArr, function (i, cssfile) {
                              b.push("<link rel='stylesheet' type='text/css' href='" + cssfile + "' />");
                          });
                          // vLookup CSS
                          b.push("<style type='text/css'>" + unescape(spjs.vLookup.data.css) + "</style>");
                          // The below line will try to force Chrome so include backgrounds and colors to you don't have to turn it on in the print dialog
                          b.push("<style type='text/css'>body{-webkit-print-color-adjust:exact!important;color-adjust:exact!important;}</style>");
                          // Header
                          if (spjs.dffs.data.dffsDataObj.tabs.printHeader !== "") {
                              pHead = spjs.dffs.buildValStr(unescape(spjs.dffs.data.dffsDataObj.tabs.printHeader));
                              pHead = spjs.dffs.translateStringWithJSON(pHead);
                              b.push(pHead);
                          }
                          // Add formtable HTML
                          b.push("<table class='ms-formtable dffs-print'>" + jQuery(".ms-formtable").html() + "</table>");
                          // Footer
                          if (spjs.dffs.data.dffsDataObj.tabs.printFooter !== "") {
                              pFoot = spjs.dffs.buildValStr(unescape(spjs.dffs.data.dffsDataObj.tabs.printFooter));
                              pFoot = spjs.dffs.translateStringWithJSON(pFoot);
                              b.push(pFoot);
                          }
                          iframe.ready(function () {
                              var contentWindow = document.getElementById("dffs_print_form").contentWindow;
                              contentWindow.document.write(b.join(""));
                              contentWindow.document.close();
                              setTimeout(function () {
                                  var printOK = contentWindow.document.execCommand('print', false, null);
                                  if (!printOK) {
                                      contentWindow.focus();
                                      contentWindow.print();
                                  }
                                  setTimeout(function () {
                                      jQuery("#dffs_print_form").remove();
                                  }, 500);
                              }, 1000);
                          });
                      };

                      Alexander

                    • #23450
                      HYM
                      Participant

                        okay great everything is working fine now i copied also the spjs_path and i will update my print function in DFFS_fronted_min.js file now.

                        thank you.

                      • #23461
                        Alexander Bautz
                        Keymaster

                          Thanks for the feedback. I will be replacing the current function with this in the next release of DFFS – hopefully during next weekend.

                          Alexander

                      Viewing 9 reply threads
                      • You must be logged in to reply to this topic.