Submitted by Anonymous (not verified) on Thu, 09/01/2016 - 19:14
Forums

Hi,

How do I place a word document in the IceBreak Response?

Regards,

James

Niels Liisberg

Fri, 09/02/2016 - 10:45

Hi James,

VBscript is not the weapon of choice in modern web applications. Microsoft has (kind of) lost the browser battle. So for the same reason, do not use active-x components which is only supported in IE.

A much better and more cross browser friendly solution is direct serving the word document, and set the propper content type and disposition.

Basically your code looks like this:  

<%@ language="RPGLE"  %>
<%
/* -----------------------------------------------------------------------------
* Program . . : include a word documnet
* ----------------------------------------------------------------------------- */
var msg     varchar(512)

/free
  *INLR = *ON; 

  // let the browser-plugin have time to load the file
  setCacheTimeout(10);

  // Word need this MIME type
  setContentType(
    'application/vnd.openxmlformats-' +
    'officedocument.wordprocessingml.document'
  );

  // What do we call it on the client, and should we download or show it in the broser window
  setHeader (
    'Content-Disposition' :
    'inline; filename="MyClientDocument.docx"'
  );  

  // Now get the payload
  msg = include ('myWordDoc.docx');

  // If error, sound the alarm
  if msg > '';
    setContentType('text/html');
    %>Error opening document, reason: <%= msg %><%
  endif;

Note: The document is read only, if you need to modify /save you need another technique. Textarea or web-dav. which is another ballgame..

Best regards,

Niels Liisberg