Home › Forums › General discussion › Passing rich text field to Word or PDF document
- This topic has 8 replies, 2 voices, and was last updated 4 years, 2 months ago by MikeS.
-
AuthorPosts
-
-
September 25, 2020 at 21:38 #31674
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,
MikeSAttachments:
-
September 26, 2020 at 08:48 #31683
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
-
September 28, 2020 at 17:33 #31695
Where is “dffs_noPrint” entered?
-
September 28, 2020 at 19:10 #31697
You find this line in the code snippet I sent:
jQuery("#dffs_" + fin).addClass("dffs_noPrint");
Alexander
-
-
September 28, 2020 at 19:37 #31703
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
-
September 28, 2020 at 19:56 #31709
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
-
September 28, 2020 at 22:21 #31725
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 -
September 29, 2020 at 17:03 #31742
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
-
September 29, 2020 at 22:27 #31760
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
-
-
AuthorPosts
- You must be logged in to reply to this topic.