Programatically setting the page to print in landscape format

Discussion in 'Internet Explorer' started by spc197, Aug 5, 2008.

  1. spc197

    spc197 Guest

    I have an ActiveX which works beautifully in IE6 to set the page to print in
    landscape.

    In the development department we have upgraded to IE7 before the rest of the
    group so we can test out certain parts of the system for problems

    The ActiveX function does not work in IE7. I have done some research and
    tried creating a page with CSS rules setting the @page attribute to landscape
    with no sucess.

    Please can you point me in the right direction for setting the page
    orientation through the code and not allowing the user to change it

    Thanks
     
    spc197, Aug 5, 2008
    #1
    1. Advertisements

  2. spc197

    rob^_^ Guest

    Hi spc,

    I played around with the suggestions at http://www.devx.com/tips/Tip/32962

    re:

    <style type="text/css" media="print">
    @page
    {
    size: landscape;
    margin: 2cm;
    }
    </style>


    and it does not seem to work as expected (another test for IE8 Beta 2)...

    There have been a lot of posts about this problem... generally the solution
    has either been to use an ActiveX or disable the print setup functions with
    group policy.... users can print directly to the default printer by pressing
    the Print button on the Command Bar (note: click the button, do not select
    Print from the Drop-down menu - this displays the Printer selection dialog
    before printing).

    I have to ask, why doesn't your ActiveX work with IE7? I suspect that it is
    using the execmd method, in which case check your security settings -
    "Enable scripting of the web browser control" (this should allow your
    activeX to use the web browser methods for printing the page.) or "Allow
    scripting of ActiveX controls".

    Please post back if these solutions work.

    Search the IE7 Extensions Development forum for "Printing direct" -
    http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=924&SiteID=1 to see
    additional solutions offered.

    Regards.
     
    rob^_^, Aug 5, 2008
    #2
    1. Advertisements

  3. spc197

    rob^_^ Guest

    Hi,

    As well as the size attribute in the @page block you need to add the W3C
    defaults

    @media print {
    @page { margin: 10% ; size: landscape}
    H1, H2, H3,
    H4, H5, H6 { page-break-after: avoid; page-break-inside: avoid }
    BLOCKQUOTE,
    PRE { page-break-inside: avoid }
    UL, OL, DL { page-break-before: avoid }
    }

    You may also want to add tags, ids and classes that you want hidden when the
    page is printed. eg. #divHeader {display:none}

    This is best done with an external stylesheet

    <link type="text/css" href="W3CPrint.css" media="print" /> (remove the
    @media print block from the above example).

    Regards.
     
    rob^_^, Aug 5, 2008
    #3
  4. spc197

    spc197 Guest

    Thanks for the reply to my post.

    I have tried the stylesheet rules you suggested but with no sucess

    The DLL is built in VB6 and accessed from a mixture of ASP and ASP.net
    pages. The VB6 is using the winspool.drv. Do you have an example of activeX
    code I could try as an alternative to the one we are currently using?
     
    spc197, Aug 6, 2008
    #4
  5. spc197

    rob^_^ Guest

    Hi,

    Did you check the security settings to see if ActiveX or WebBrowser control
    scripting is disabled?

    The Extension Development Forum -
    http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=924&SiteID=1 is the
    place to post detailed questions about ActiveX functionality and IE.

    Here is the VB6 snippet to print directly to the default printer.

    Call MyWb.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 1)

    (You can embed a similar script into a web page, but a user needs to have
    allowed scripting of the WebBrowser control in their security settings). See
    the Forum above for other solutions offered.

    The method will use the paper orientation that has been set for the default
    printer and avoids the Printer Setup dialog so the user cannot change the
    settings.

    Regards.
     
    rob^_^, Aug 6, 2008
    #5
  6. spc197

    spc197 Guest

    Thanks for the reply
    Yes I checked the settings were allowing ActiveX, I even went so far to
    allow everything to run to see if that would make a difference but no luck
    Thanks for this code snippet. I have tried using this already and tried to
    use it with the Page Setup ability to change the orientation to landscape but
    was unsur of what to pass in for ref parIn.

    Thanks for the link to the extension development forum. Ill post a question
    there.
     
    spc197, Aug 7, 2008
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.