8

I am developing an application which generates pdf using ITextSharp and need to print silently or directly. My work flow is Like this, I have some forms listed in tree structure and on selecting the forms and click on the print button will automatically generate the pdf using Itextsharp and save to a location. this is because for multiple record we download it as zip file . And goes to print without opening any other windows. I am using google chrome as browser and uses the KIOSK mode.

But unfortunately when i execute the code the print preview will open up in my browser and i need to click on the back button to reach my page. I want this to be cleared. Also i need to clear the selection of the tree structure.

Hereby attaching the code while printing.

MemoryStream ms = new MemoryStream();
var urlPdf = Server.MapPath("~/Pdf/pdfMerge/" + id + "Merge_doc.pdf");
PdfReader ps = new PdfReader(urlPdf);//1
PdfStamper pdf = new PdfStamper(ps, ms);//2
pdf.JavaScript = "this.print({bUI: true,bSilent:false,bShrinkToFit: true});" + "\r\n" + "this.closeDoc();";//3
pdf.Close();//4
HttpContext.Current.Response.ClearContent();//5
HttpContext.Current.Response.ClearHeaders();//6
HttpContext.Current.Response.ContentType = "application/pdf";//7
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=quickforms.pdf");//8
HttpContext.Current.Response.BinaryWrite(ms.ToArray());//9
ms.Flush();

Can anybody help me?

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
Sivajith
  • 1,181
  • 5
  • 19
  • 38
  • I'm not familiar with your JavaScript parameters but wouldn't you want `bUI: false,bSilent:true`, so *no* UI is shown and it prints silently? – Chris Haas Dec 16 '13 at 14:10
  • no change happens even if i changed that code – Sivajith Dec 18 '13 at 11:22
  • 1
    Can you tell us where you found the documentation for these parameters? – Chris Haas Dec 18 '13 at 13:46
  • For your sanity, the print parameters (bUI, bSilent, bShrinkToFit) are documented in "Developing Acrobat Applications Using JavaScript" - "Printing PDF Documents": http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_developer_guide.pdf – Omar Aug 28 '14 at 01:35

2 Answers2

14

Use

--kiosk --kiosk-printing <application_URL>

Create a new chrome.exe shortcut Add –kiosk –kiosk-printing flags to the chrome.exe target shortcut Add the url of the kiosk as the starting page in Chrome settings (or replace chrome.exe with “chrome.exe –kiosk http:// [enter URL here]”) Drag the shortcut into the startup folder so it loads automatically.

That’s it! Then when you open it’s fullscreen and locked down with the kiosk and auto printing functionality all in one! :) To quit the Kiosk, press Alt + F4 on your keyboard.

rajivas
  • 151
  • 1
  • 6
6

MUST USE:
PRINT DIRECT: --kiosk-printing
KIOSK MODE: --kiosk [application_url]
KIOSK MODE & PRINT DIRECT: --kiosk-printing --kiosk [application_url]

Machavity
  • 30,841
  • 27
  • 92
  • 100
DucNguyen
  • 61
  • 1
  • 1