javascript - Print PDF Created using itextsharp -



javascript - Print PDF Created using itextsharp -

my goal print rdlc study on client machine without preview. can not utilize reportviewer print button since requires installation of activex object , there no permissions that. so, i'm using itextsharp create pdf byte array returned rendered localreport, , add together javascript print.

during debug, can see pdf generated , has 2 pages, , looks ok. don't receive errors , function exits ok, doesn't print. doing wrong, or missing?

this code:

string jsprint = "var pp = this.getprintparams();pp.interactive= pp.constants.interactionlevel.silent;this.print(pp);"; byte[] bytes = report.render("pdf", null, out mimetype, out encoding, out extension, out streamids, out warnings); using (memorystream ms = new memorystream()) { document doc = new document(); pdfwriter author = pdfwriter.getinstance(doc, ms); doc.setpagesize(pagesize.a4); doc.open(); pdfcontentbyte cb = writer.directcontent; pdfimportedpage page; pdfreader reader = new pdfreader(bytes); int pages = reader.numberofpages; (int = 1; <= pages; i++) { doc.setpagesize(pagesize.a4); doc.newpage(); page = writer.getimportedpage(reader, i); cb.addtemplate(page, 0, 0); } pdfaction jaction = pdfaction.javascript(jsprint, writer); writer.addjavascript(jaction); doc.close(); }

thanks.

regarding question pdfstamper (in comments). should simple this:

string jsprint = "var pp = this.getprintparams();pp.interactive= pp.constants.interactionlevel.silent;this.print(pp);"; pdfreader reader = new pdfreader(bytes); memorystream stream = new memorystream(); pdfstamper stamper = new pdfstamper(pdfreader, stream); stamper.writer.addjavascript(jsprint); stamper.close(); reader.close();

regarding original question: automatic printing of pdf documents considered beingness security hazard: 1 send pdf end-user , pdf cause printer spew out pages. used possible (really) old pdf viewers, modern viewers prevent happening.

in other words: may trying meet requirement of past. today's pdf viewers require action end user print pdf document.

javascript c# asp.net itextsharp rdlc

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -