简体   繁体   中英

Print PDF from javascript

I am using the below mentioned code in my VB.net application to print two copies of pdf document.

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.

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("}")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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