Windows Dev Center

WebBrowser.ShowPrintDialog() question


  • Is it possible to force the .ShowPrintDialog() to use Landscape mode by default?  Or is it possible to use a custome PrintDialog object and input the HtmlFile into that with custom settings?
    Friday, November 16, 2007 7:35 PM


All replies

  • you can use print templates
    mshtml.IHTMLDocument2 doc = WebBrowser.Document as mshtml.IHTMLDocument2;
    doc.execCommand(IDM_PRINT,showUI, customPrintTemplatePath);


    In your template you need to change the orientation property of the templateprinter object.
    Saturday, November 17, 2007 2:57 AM
  • mshtml.IHTMLDocument2 doc = ticketPrint.Document as mshtml.IHTMLDocument2;

    gives the error:
    Error    1    Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.IHTMLDocument2' via a built-in conversion

    I did add the reference to the Microsoft.mshtml from the interop's dlls in c:\program files\\ -- was this not the correct DLL or am I missing something?
    Tuesday, November 20, 2007 2:32 PM
  • mshtml.IHTMLDocument2 doc = ticketPrint.Document.DomDocument as mshtml.IHTMLDocument2;
    Tuesday, November 20, 2007 2:38 PM
  • I'm using C# if anyone's wondering but this is what I have from reading various other attempts at it:

    Code Block



       <IE:TEMPLATEPRINTER id="Printer"/>
    <SCRIPT Language="JavaScript">

    This is the layout of the HTML page (it contains these new additions to the structure).  Now, inside my C# code I have:

                mshtml.IHTMLDocument2 doc = ticketPrint.Document.DomDocument as mshtml.IHTMLDocument2;
                doc.execCommand("print", true, 0);

    However, this doesn't work, and I'm assuming it has something to do with the 0.  Is there any other way I can specify the landscape directly into the place of 0?

    Tuesday, November 20, 2007 3:55 PM
  • Hi,


    I have the same problem. How did you solve it?





    Wednesday, December 12, 2007 3:18 PM
  • Unfortunately no, I can't seem to find any more information unless it applies to C++ specifically (the code for any C# application doesn't mimic it for C++).
    Friday, December 14, 2007 8:14 PM