简体   繁体   English

从javascript打印PDF

[英]Print PDF from javascript

I am using the below mentioned code in my VB.net application to print two copies of pdf document. 我在VB.net应用程序中使用下面提到的代码来打印pdf文档的两个副本。

js.Append("var pp = this.getPrintParams();")
    js.Append("var iCopies = 2;")
    js.Append("var iPages = this.numPages;")
    js.Append("pp.NumCopies = iCopies;")
    js.Append("pp.interactive = pp.constants.interactionLevel.silent;")
    js.Append("for ( var i = 0; i < iPages; i++ ) { pp.firstPage = i; pp.lastPage = i;")
    js.Append("this.print(pp);")
    js.Append("}")

It is working great. 运行良好。 But how can I make the last page print only 1 copy instead of two copies. 但是如何使最后一页仅打印1份而不是2份。

Your help greatly appreciated. 非常感谢您的帮助。

js.Append("for ( var i = 0; i < iPages; i++ ) { pp.firstPage = i; pp.lastPage = i;")
js.Append("if(i == (iPages - 1)) pp.NumCopies = 1; ") ' This line does it
js.Append("this.print(pp);")
js.Append("}")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM