采用break{page-break-after:always}打印分页时,为啥第一页是空白呢?谁能解决这个问题.

pass2005 2005-04-07 10:57:45
我是需要打印信封,所以格式要有控制,就是要控制打印的准确位置,用加空格强制页面分页打印的话,第一个打印的位置有后面其他的页打印的位置就有差别.
...全文
1577 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pkcai 2005-04-25
  • 打赏
  • 举报
回复
本公司域名特价销售
.com50元,.cn55元
绝对新网域名
空间,数据库
联系QQ322062
tigerhu76 2005-04-25
  • 打赏
  • 举报
回复
mark
Accelerator 2005-04-25
  • 打赏
  • 举报
回复
我说错了,应该不会有空白的现象。
第一页不加style="page-break-after:always;"就可以了。
yql2004 2005-04-24
  • 打赏
  • 举报
回复
用style="page-break-after:always;"试试
我也在做WEB打印,不会有第一页是空白的现象
Accelerator 2005-04-23
  • 打赏
  • 举报
回复
随便设个变量就判断了呀
例如:
<%
bPage=true
while not rs.eof
if bPage then
....
bPage=false
else
....
end if
rs.movenext
wend
%>
pass2005 2005-04-21
  • 打赏
  • 举报
回复
怎么判断是第一页呢?
Accelerator 2005-04-15
  • 打赏
  • 举报
回复
我也遇到了这样的问题,不过是最后一页出现空白页。找了半天的CSDN,没有找到答案,只好尝试自己来解决。

我用了下面的方法后没有出现空白页:
将第一页设为style='page-break-inside:always
以后的页面都设为style='page-break-before:always'

可能css中还有更简便的格式定义方法,需要你自己去尝试了。
qmei 2005-04-11
  • 打赏
  • 举报
回复
可能是页边距的问题,还有就是body等元素的top-margin等属性都要设置为0,
有兴趣的话,可以看看http://www.fcsoft.com.cn/eprint/index.htm这个页面里面的“强制分页的示例”
pass2005 2005-04-11
  • 打赏
  • 举报
回复
怎么都没人会么?
pass2005 2005-04-07
  • 打赏
  • 举报
回复
怎么都没人会么?
【利用WebBrowser彻底解决Web打印问题(包括后台打印) 】利用WebBrowser彻底解决Web打印问题(包括后台打印)BS架构下的打印大家是怎么解决的呢,我最近作了一个项目正好负责这一块,不仅要求打印页面的特定部分,还要求有后台的批量打印,在网上查了一些资料,最后终于解决了。抱着“取之于众 服务于众”的思想,我总结了一下,把它拿到网上来与大家分享,希望能帮助遇到类似问题的朋友。我主要使用了IE内置的WebBrowser控件,无需用户下载和安装。WebBrowser有很多功能,除打印外的其他功能就不再赘述了,你所能用到的打印功能也几乎全部可以靠它完成,下面的问题就是如何使用它了。先说显示后打印,后面说后台打印。1.首先引入一个WebBrowser在需要打印的页面,可以直接添加:到页面,或者使用JavaScript在需要的候临添加也可以:document.body.insertAdjacentHTML("beforeEnd","");2 .页面设置和打印预览如下所示,直接调用即可document.all.WebBrowser.ExecWB(6,6) 直接打印document.all.WebBrowser.ExecWB(8,1) 页面设置document.all.WebBrowser.ExecWB(7,1) 打印预览或者:execScript("document.all.WebBrowser.ExecWB 7, 1","VBScript");3 隐藏不打印的页面元素和分页CSS 有个Media 属性,可以分开设置打印和显示的格式。如 … 中间的格式将只在打印起作用,不会影响显示界面。所以可以设定.Noprint{display:none;}.PageNext{page-break-after: always;}然后给不想打印的页面元素添加: class="Noprint" ,那就不会出现在打印打印预览中了。想分页的地方添加: 就可以了。4.打印页面的特定部分我是通过将需要打印的特定部分另建一个页面,然后装入主页面的一个IFrame中,再调用IFrame的打印方法,只打印IFrame中的内容实现的。如:下面的pringFrame js函数将只打印Iframe中的内容,可以直接引用使用,如printFrame(FrameId);window.print = printFrame;// main stufffunction printFrame(frame, onfinish) {if ( !frame ) frame = window;function execOnFinish() {switch ( typeof(onfinish) ) {case "string": execScript(onfinish); break;case "function": onfinish();}if ( focused && !focused.disabled ) focused.focus();}if (( frame.document.readyState !== "complete") &&( !frame.document.confirm("The document to print is not downloaded yet! Continue with printing?") )){execOnFinish();return;}var eventScope = printGetEventScope(frame);var focused = document.activeElement;window.printHelper = function() {execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");printFireEvent(frame, eventScope, "onafterprint");printWB.outerHTML = "";execOnFinish();window.printHelper = null;}document.body.insertAdjacentHTML("beforeEnd","");printFireEvent(frame, eventScope, "onbeforeprint");frame.focus();window.printHelper = printHelper;setTimeout("window.printHelper()", 0);}// helpersfunction printIsNativeSupport() {var agent = window.navigator.userAgent;var i = agent.indexOf("MSIE ")+5;return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;}function printFireEvent(frame, obj, name) {var handler = obj[name];switch ( typeof(handler) ) {case "string": frame.execScript(handler); break;case "function": handler();}}function printGetEventScope(frame) {var frameset = frame.document.all.tags("FRAMESET");if ( frameset.length ) return frameset[0];return frame.document.body;}Iframe中所装载页面的打印效果在所装载页面设置就可以了,如分页等。5.后台打印我是通过建一个隐藏Iframe实现的,当然仍然会有页面装载的过程。下面的函数创建Iframe装载页面并打印。如 printHidden(url) //url为页面地址function printHidden(url) {document.body.insertAdjacentHTML("beforeEnd","");var doc = printHiddenFrame.document;doc.open();doc.write("");doc.write("");doc.write("");doc.close();}function onprintHiddenFrame() {function onfinish() {printHiddenFrame.outerHTML = "";if ( window.onprintcomplete ) window.onprintcomplete();}printFrame(printHiddenFrame.printMe, onfinish);}它用到了printFrame,所以别忘了引用前面的函数。总之,WebBroswer已经为我们提供了解决方案,我们只要结合需求把它应用好就行了。
重点: <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT> </OBJECT> <input type=button value=打印 " class= "NOPRINT "> <input type=button value=直接打印 " class= "NOPRINT "> <input type=button value=页面设置 " class= "NOPRINT "> <input type=button value=打印预览 " class= "NOPRINT "> 注意: 1、CSS对打印的控制: <!--media=print 这个属性可以在打印有效--> <style media=print> .Noprint{display:none;} .PageNext{page-break-after: always;} </style> Noprint样式可以使页面上的打印按钮等不出现在打印页面上,这一点非常重要,因为它可以用最少的代码完成最需要的功能 PageNext样式可以设置分页,在需要分页的地方 就OK了,呵呵 2、表格线粗细的设置,更是通过样式表: <style> .tdp { border-bottom: 1 solid #000000; border-left: 1 solid #000000; border-right: 0 solid #ffffff; border-top: 0 solid #ffffff; } .tabp { border-color: #000000; border-collapse:collapse; } </style> 或者: <style> .TdCs1 { border:solid windowtext 1.0pt; } .TdCs2 { border:solid windowtext 1.0pt; border-left:none; } .TdCs3 { border-top:none; border-left:solid windowtext 1.0pt; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; } .TdCs4 { border-top:none; border-left:none; border-bottom:solid windowtext 1.0pt; border-right:solid windowtext 1.0pt; } .underline { border-top-style: none; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-bottom-color: #000000; } </style> 1、控制 "纵打 "、 横打”和“页面的边距。 (1) [removed] function SetPrintSettings() {  // -- advanced features  factory.printing.SetMarginMeasure(2) // measure margins in inches  factory.SetPageRange(false, 1, 3) // need pages from 1 to 3  factory.printing.pri

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧