How to access the Internet Explorer's print function

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
sandyH
Posts: 5
Joined: Mon Mar 22 2004

How to access the Internet Explorer's print function

Post by sandyH »

Hi,

Could somebody tell me how to access the Internet Explorer's print function in .net web application? I am using c# codebehind. I need to convert htm file to pdf using the pdf Converter. Any response will be highly appreciated.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

Can you clarify if you want to print the HTML page on your sever and sent the PDF document back to the clients system?


Thanks
sandyH
Posts: 5
Joined: Mon Mar 22 2004

Post by sandyH »

Thanks for replying. Yes, I want to print the HTML page on my sever and sent the PDF document back to the clients system. we use ms word to open .doc files and set the printer, So I was thinking to use internet explore to open html file, and set the printer, but how? Do you have any other way to do it?
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

The code snippet below will print the contents of the WebBrowser control which is on a form to the installed PDF Converter printer driver. You can modify this sample to fit your needs.

//create PDF printer constants
const string PDFprinter = "Amyuni PDF Converter";
const string strLicenseTo = "Amyuni Eval";
const string strActivationCode = "07EFCDAB010001003603981D53F1BABC361DE6BAE584B797D0EFDE5F8BA4A978E56027E48DED7954CEBE795D4D22FF42988E30854D8A3FA7D5B695478B85980A759A93A018CF9B459446E65FC15197C41697370F344A397C7B8E5A";
const Int64 sNoPrompt = 0x01;
const Int64 sUseFileName = 0x02;


private void Form1_Load(object sender, System.EventArgs e)
{

//Load WebBrowser control with page you which to print.
object oURL = @"C:\Inetpub\wwwroot\WebApplication1\login.aspx";
object oEmpty = "";
axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty);
}


private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
// When document complete event is fired then print
// to the PDF Converter
//Debug code== please remove
MessageBox.Show ("DocumentComplete event fired!");
//print when this event fires
object obj3 = null,obj4 = null;


//Set up Printer
CDIntfEx.CDIntfEx PDF = new CDIntfEx.CDIntfExClass() ;
PDF.DriverInit ( PDFprinter);
PDF.DefaultDirectory = "c:\\temp";
PDF.DefaultFileName = "c:\\temp\\fromCsharp.pdf";

//Set printer as default
// Typically on a server you would the Printer the default
// printer and not change it in code
PDF.SetDefaultPrinter();
PDF.FileNameOptions = (int) (sNoPrompt + sUseFileName);
PDF.EnablePrinter (strLicenseTo, strActivationCode);

axWebBrowser1.ExecWB ( SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER ,ref obj3,ref obj4);

PDF.RestoreDefaultPrinter ();
PDF.DriverEnd ();
}



Hope this helps?
Post Reply