PrintAsPDFAction.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2013
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. function PrintAsPDFAction() {
  13. this.m_format = "PDF";
  14. this.m_responseFormat = "page";
  15. }
  16. PrintAsPDFAction.prototype = new ExportAction();
  17. PrintAsPDFAction.prototype.getWindowTitle = function() {
  18. return RV_RES.IDS_PRINT_AS_PDF;
  19. };
  20. PrintAsPDFAction.prototype.initializeForm = function() {
  21. this.nForm = document.createElement("form");
  22. this.nForm.setAttribute("method", "post");
  23. var sDispatcherURI = location.protocol +'//'+ location.host + this.m_oCV.m_sGateway;
  24. this.nForm.setAttribute("action", sDispatcherURI);
  25. };
  26. PrintAsPDFAction.prototype.sendRequest = function() {
  27. var viewerID = this.m_oCV.getId();
  28. var sName = 'get' + this.m_format + viewerID;
  29. this.nForm.setAttribute("id",sName);
  30. this.nForm.setAttribute("name", sName);
  31. this.nForm.setAttribute("target", this.m_format + 'Window' + viewerID);
  32. document.body.appendChild(this.nForm);
  33. var sWindowId = this.nForm.getAttribute("target");
  34. window.open("",sWindowId,'resizable=yes,menubar=no,directories=no,location=no,status=no,toolbar=no,titlebar=no');
  35. this.nForm.submit();
  36. document.body.removeChild(this.nForm);
  37. this.nForm = null;
  38. return true;
  39. };
  40. PrintAsPDFAction.prototype.addFormField = function(sName, sValue) {
  41. this.nForm.appendChild(createHiddenFormField(sName, sValue));
  42. };