Passing rich text field to Word or PDF document

Home Forums General discussion Passing rich text field to Word or PDF document

Viewing 7 reply threads
  • Author
    Posts
    • #31674
      MikeS
      Participant

        Alexander,
        I understand the reluctance for using Rich Text Field (RTF) and usually steer clear of them. However unique requirements (need to show strike-thru, bold, red text, table) in a RTF field that can then be exported to a Word or PDF document have arisen. Extensive research indicates that a SharePoint Designer (SPD) workflow will not copy a List or Document Library RTF to a Word document. SPD passes it as a string that then displays the encoded HTML in the Word document.

        Printing the Display form using the DFFS print capability might be an option, but there are numerous format issues that would have to be accommodated. For example, there are 130 possible fields in the form but a varying number ranging from 10 to 50 would be printed at any one time. Excluding non-populated fields would require some JS perhaps. Landscape format is needed, footer on every page, etc.

        I’ve attached three screen shots that show the RTF and the resultant encoded HTML in the Word doc after the workflow runs.

        An alternate solution is needed and I wondered if you had any suggestions.

        Thanks,
        MikeS

      • #31683
        Alexander Bautz
        Keymaster

          Excluding fields from being printed using the built in DFFS print functionality (Email and print tab in DFFS config) can be done by adding the class dffs_noPrint to the rows with custom code.

          Try this snippet in your custom js:

          // Overrides the default print fn
          var originalPrintFn = spjs.dffs.printCurrentTab;
          spjs.dffs.printCurrentTab = function () {
              // Array of fields to check that they have a value (use internal name)
              var arrOfFields = ["Field1", "Field2", "Field3"];
              jQuery.each(arrOfFields, function (i, fin) {
                  var val = getFieldValue(fin);
                  if (val === "") {
                      jQuery("#dffs_" + fin).addClass("dffs_noPrint");
                  }
              });
              // Call the original fn
              originalPrintFn();
          };

          You can add a header and footer in the Email and print tab in the DFFS config, but selecting landscape mode must be done in the print preview window in the browser.

          Alexander

        • #31695
          MikeS
          Participant

            Where is “dffs_noPrint” entered?

            • #31697
              Alexander Bautz
              Keymaster

                You find this line in the code snippet I sent:

                jQuery("#dffs_" + fin).addClass("dffs_noPrint");

                Alexander

            • #31703
              MikeS
              Participant

                Placing the above JS in the Display form Custom JS and updating the JS with my FINs does not prevent blank fields from being printed. Must be missing something.

                MikeS

              • #31709
                Alexander Bautz
                Keymaster

                  You must add your own list of field in this array:

                  // Array of fields to check that they have a value (use internal name)
                  var arrOfFields = ["Field1", "Field2", "Field3"];

                  Alexander

                • #31725
                  MikeS
                  Participant

                    Works great! I had the wrong FIN entries.

                    Can you think of any way to get a header and footer on each page, vs. a single header at the beginning and a single footer on the final page?

                    Thanks,
                    MikeS

                  • #31742
                    Alexander Bautz
                    Keymaster

                      Sorry, but this is not so easy because the paper size and margins on your printer will make it impossible to control the placement of the header and footer because they would have to be passed with the main body of the document exactly at the start and end of each page.

                      It is possible to use js to create a docx file using third party code, but this is unfortunately not something I can help you with. Search

                      Alexander

                    • #31760
                      MikeS
                      Participant

                        I understand. The print function is very handy and alleviates a shortcoming in SPD relative to the handling of Rich Text fields.

                        Thanks for your help,
                        MikeS

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