1.  You will need a Long character field to hold the HTML string. You can use the delivered field HTMLAREA if there is no need to create a custom field.

2.  Create a new page.

3.  Place an HTML Area on the page.

4.  Assign a record and field to the HTML Area Properties page. (Note: The field used for the HTML Area needs to be of type LONG character.)

5.  Verify the HTML Area is at Level0.

6.  Add the push button to the page that will kick off the Print request. Make the Destination dropdown box be “External Link”. The External Link frame should have the “Dynamic” radio button selected.

Note: Make sure that the push button field that you use is long enough to contain the code that will be added in a future step (min of 25 characters).

7.  On the General tab of the Push Button/Hyperlink Properties page, make sure to fill in a Page Field Name. For this example, you see PRINT_BTN which will be placed in the print HTML below as #PRINT_BTN. This page field name is used so that the print function knows which button(s) to hide when the page is printed.

8.  Add the following PeopleCode to the Component Record PeopleCode RowInit event.

MY_TEST_WRK.HTMLAREA.Value = "<style type=""text/css"">@media print {body { zoom:80%;} #PAGEBAR,.PSHEADERTOOLBARFRAME, #PRINT_BTN { display: none }}</style>";

Explanation of the HTML above:

Zoom: The percentage listed after zoom will be how to shrink the web page on the printout (or expand if greater than 100). In this example, the HTML is printing the page at 80% of its normal size.

#PAGEBAR and .PSHEADERTOOLBARFRAME get a handle on the delivered PeopleSoft headers and navigation bar on the page.  By also listing #PRINT_BTN the HTML is instructed to hide these areas on the printed page.

Additional buttons that you have on your page can be placed into this HTML text. The Page Name field just needs to be prefaced with the pound symbol (#).

All buttons that you desire to hide must be at Level0.

Alternatively, the code can be placed as a constant value on the HTML Area Properties page if the zoom percentage will never change (page size remains constant).

To dynamically control the percentage to shrink or expand the output, use code similar to this and place in a function that would be called whenever the page dimensions are changed by user activity:

/* I Want to dynamically control Page Percentage so all will fit */&Percnt = 80 - &somenumber_or_equation;MY_TEST_WRK.HTMLAREA.Value = "<style type=""text/css"">@media print {body { zoom:" | &Percnt |"%;} #PAGEBAR, .PSHEADERTOOLBARFRAME, #PRINT_BTN { display: none }}</style>";

9.  On the Component Record Field PeopleCode FieldDefault event for the push button, place the following code:

MY_TEST_WRK.MY_TEST.Value = "javascript:window.print()";

10.  Run the page in the browser. The HTML area is not visible since there is no text, only a script.

11.  Pressing the Test Print button will bring up the printer dialog box where you can switch to another printer, along with setting the printing preferences (landscape vs. portrait orientation, etc):

12.  When the page prints, notice that the Test Print push button that was specified to not display is not shown on the printed page. Also, the PeopleSoft navigation bars and headers are not shown either.

Print a PeopleSoft Page with JavaScript的更多相关文章

  1. How can I get an object's absolute position on the page in Javascript?

    How can I get an object's absolute position on the page in Javascript? How can I get an object's abs ...

  2. Dynamic Prompt Table for Record Field on PeopleSoft Page

    Sometimes a situation in project work arises to have a dynamic prompt table for record fields on Peo ...

  3. (转)JAVA AJAX教程第二章-JAVASCRIPT基础知识

    开篇:JAVASCRIPT是AJAX技术中不可或缺的一部分,所以想学好AJAX以及现在流行的AJAX框架,学好JAVASCRIPT是最重要的.这章我给大家整理了一些JAVASCRIPT的基础知识.常用 ...

  4. jshint-eclipse: JavaScript Code Quality Plugin for Eclipse

    https://blog.oio.de/2012/03/26/jshint-eclipse-javascript-code-quality-plugin-for-eclipse/   techscou ...

  5. web前端基础知识-(三)JavaScript基本操作

    JavaScript 是一种轻量级的编程语言. JavaScript 是可插入 HTML 页面的编程代码. JavaScript 插入 HTML 页面后,可由所有的现代浏览器执行. JavaScrip ...

  6. 大型 JavaScript 应用架构中的模式

    原文:Patterns For Large-Scale JavaScript Application Architecture by @Addy Osmani 今天我们要讨论大型 JavaScript ...

  7. JavaScript闭包(二)——作用

    一.延迟调用 当在一段代码中使用 setTimeout 时,要将一个函数的引用作为它的第一个参数,而将以毫秒表示的时间值作为第二个参数. 但是,传递函数引用的同时无法为计划执行的函数提供参数.可以在代 ...

  8. JavaScript闭包(一)——实现

    闭包的官方的解释是:一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分. 通俗点的说法是: 从理论角度:所有的函数.因为它们都在创建的时候就将上层上下文 ...

  9. JavaScript学习(1):基础

    这篇文章里,我们来聊一些JavaScript的基础知识. 1. 如何运行JavaScript? JavaScript是一种解释型的语言,它不需要提前编译.通常情况下,JavaScript会放在网页中, ...

随机推荐

  1. Linux备份入门:3种克隆方法详解_Clonezilla

    摘自:http://os.51cto.com/art/201006/206871.htm 给你的系统磁盘制作一个镜像拷贝是创建备份的好办法.由于便携式U盘总是有比较低廉的价格,你可以维护数个拷贝以便循 ...

  2. zabbix如何监控WEB应用性能

    HTTP服务目前最流行的互联网应用之一,如何监控服务的健康状态对系统运维来说至关重要.   Zabbix本身提供了对WEB应用程序的监控,比如监控WEB程序的Download Speed,Respon ...

  3. 安装程序无法复制文件 convlog.exe的解决方法

    在安装的时候出现一个错误提示“安装程序无法复制文件CONVLOG.EX_”,上网找了很多资料,都说是因为版本问题,考虑到自己的服务器安装的是2003 SP1,后来打了补丁到SP2的,也就认为是版本问题 ...

  4. 朗逸2011款 1.4t 清除保养告警灯

    朗逸2011款 1.4t 清除保养告警灯 Posted on 2015-03-01 21:06 编辑 仪表盘上有两个按钮 按住右边set键,钥匙旋转到通电状态,保持2s. 放掉set,按左边的切换按钮 ...

  5. Flask + Gunicorn + Nginx 部署

    最近很多朋友都在问我关于 Flask 部署的问题,说实在的我很乐意看到和回答这样的问题,至少证明了越来越多人开始用 Flask 了. 之前我曾发表过一篇在 Ubuntu 上用 uwsgi + ngin ...

  6. 关于 Python Iterator 协议的一点思考

    转:http://www.jianshu.com/p/dcf83643deeb Python 中有好几种容器或者序列类型:list tuple dict set str,对于这些类型中的内容,往往需要 ...

  7. Chrome内嵌 FlashPlayer(PPAPI)会被页面DHTML元素遮住的问题

    flash的wmode为window,Chrome版本为29.0.1547.66 m,Flash PPAPI为11.8.800.97,Flash NPAPI为11,8,800,94. flash在正常 ...

  8. 蓝桥杯---地宫取宝(记忆搜索=搜索+dp)

    题目网址:http://lx.lanqiao.org/problem.page?gpid=T120 问题描述 X 国王有一个地宫宝库.是 n x m 个格子的矩阵.每个格子放一件宝贝.每个宝贝贴着价值 ...

  9. appium的xpath定位

    做自动化,元素定位是我们遇到的第一个困难.总是会有各种各样的问题,导致我们定位不到元素.前面一篇博客也写了元素定位的几种方法,今天主要分享一下xpath的定位方法. 这里我们仍然拿计算器举例. 比如我 ...

  10. leetcode题目总结(转)

    https://www.douban.com/note/330562764/   http://blog.csdn.net/lanxu_yy/article/details/17848219   ht ...