I am using the winnovative html to pdf converter for creating a pdf document. I've added a checkbox for the user to choose wether they would like to print or email the pdf file.
But i can't get the pdf page to open the printer dialog. I have tried the PrinterDialog class but this didn't work, also sending some javascript with window.print() didn't work. I've searched the internet but couldn't find anything.
My page containing the PDF has the following code:
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "inline;filename=Offerte.pdf");
Response.BufferOutput = true;
Response.AddHeader("Content-Length", downloadBytes.Length.ToString());
Response.BinaryWrite(downloadBytes); //downloadBytes = the byte array created by winnovative converter
Response.End();
This will open the pdf viewer inside the browser containing my page as PDF. From here the user is able to click the print button of the pdf viewer/browser. But i would like to have my page open the printer dialog or send the bytes directly to the printer, to minimalize the actions a user has to do.
Any ideas?
Solved it this morning, appeared to be just a stupid mistake. The winnovative converter has a parameter for enabling scripts which is by default set to false. Setting this to true enabled me to use javascript from inside the pdf.
After reading the post which was suggested to me, I found that it had to be possible to use javascript inside the PDF. After searching some more, including the FAQ from winnovative I added the following code:
Then the javascript inside the header worked!