Internet Explorer Developer Center > Internet Explorer Development Forums > Internet Explorer Web Development > Using C# Web Browser control to generate custom web page print preview window.
Ask a questionAsk a question
 

QuestionUsing C# Web Browser control to generate custom web page print preview window.

  • Monday, November 02, 2009 1:42 PMRamanand Bhat Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    We would like to implement custom print preview window for any general web page loaded onto c# WebBrowser control.

    In order to have our custom requirement attached and for our customer requirement we cann't use print and print preview features implemented in webbrowser control such as executing ExecWB() commands or calling print review method over webbrowser control.

    How to generate preview window with print style-sheet applied to it, can we get to know the idea of print preview feature that the browser uses.

    Any help will be greatly appreciated.   

    Thank you.
    Ramanand Bhat.

All Replies

  • Tuesday, November 03, 2009 7:35 AMIECUSTOMIZERMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Try using Alternate stylesheets.


     

        <link id="styNormal" title="Normal" rel="alternate stylesheet" type="text/css" href="Normal.css" media="screen" />
        <link id="styPrintPreview" title="Print Preview" rel="alternate stylesheet" type="text/css" disabled="disabled" href="PrintPreview.css" media="screen" />


    You can the use the stylesheets collection in javascript to toggle the disabled attribute of each of the external stylsheets.

    Note: you will need to add also a media="Print" link also so that when your page is actually printed that it will use the same "PrintPreview" stylesheet.

    <link rel="stylesheet" type="text/css"  href="PrintPreview.css" media="print" />

    so you end up with a block of style links that looks like

    <link rel="stylesheet" type="text/css"  href="PrintPreview.css" media="print" />
        <link id="styNormal" title="Normal" rel="alternate stylesheet" type="text/css" href="Normal.css" media="screen" />
        <link id="styPrintPreview" title="Print Preview" rel="alternate stylesheet" type="text/css" disabled="disabled" href="PrintPreview.css" media="screen" />



    Regards.



    Rob^_^