Solved

change page orientation/font size

Posted on 2001-08-14
18
473 Views
Last Modified: 2013-12-02
Is there any way to change the page orientation to landscape for printing with code. Also is there a way to change the font size. Not the font size in the html, but the setting in IE, view menu-> fonts.

0
Comment
Question by:vortex99
  • 7
  • 4
  • 3
  • +2
18 Comments
 
LVL 9

Expert Comment

by:msdixon
Comment Utility
not that i'm aware of without some sort of activex object or something like that. it would also be a permissions issue.

i'm interested to see if anyone thinks it can be done.
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
must be an activeX solution executing at the client
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
There is a solution for IE 5, I have not tried it with any other versions;

<HTML>
<HEAD>
<OBJECT ID="wbp"
CLASSID="CLSID:778C58A9-81B6-11D3-BB8F-00C04FA3471C">
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
    Sub Print()
        If Len(wbp.DefaultPrinterName) = 0 Then
            MsgBox "No default printer!"
            Exit Sub
        End If
        wbp.Header = "My Header"
        wbp.Orientation = 2 ' Landscape
        wbp.Print
    End Sub
</SCRIPT>
</HEAD>
<BODY>
<INPUT TYPE="BUTTON" VALUE="Print" ONCLICK="Print()">
</BODY>
</HTML>

Good reference here; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/wb_print.asp
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
looks like an activeX solution...what is the wbp object?
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Web Browser Print, delivered with IE3.

I'm doing some research on this right now cause this subject has come up in a discussion with a customer yetserday so I too have a need to know... but right now it looks like a VB or ActiveX solution.

Check out the link I posted, it's full of great info.

0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
The MEDIA attribute allows you to define a CSS style for display on the screen, on a printed document, or both. You can use the MEDIA attribute with the LINK and STYLE elements. Values for MEDIA are SCREEN, PRINT, and ALL. The default is SCREEN, so leaving the MEDIA attribute unspecified causes the style sheet to always be applied to the page for the screen as well as printing. PRINT specifies that the style sheet is used for printing. None of the attributes defined in the PRINT style will be in effect on screen. The ALL value determines that the document is formatted for both the screen and print.

Here is an example that demonstrates using the MEDIA attribute with an inline style. Note that there are two STYLE elements, one with MEDIA="PRINT" and another with MEDIA="SCREEN". The screen version displays white text on a black background, and the printed version displays black text on a white background.

<HTML>
  <HEAD>
    <STYLE MEDIA="PRINT">
      BODY { background-color:white; color:black; }
    </STYLE>
    <STYLE MEDIA="SCREEN">
      BODY { background-color:black; color:white; }
    </STYLE>
  </HEAD>
  <BODY>
    This is a test.
  </BODY>
</HTML>

Here is an example of how you would specify a linked style sheet that applies when printing:

<LINK REL="stylesheet" HREF="print.css" MEDIA="PRINT">

You can also specify custom margins when printing using the margin style properties, but these are offset from the margins specified by the Page Setup margins.

0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
Actually I have posted that link here before for others who have asked this question (just now realized the have altered the URL so i didnt recognize it right off).

It is an activeX solution, but since its from MS, it may be signed/safe but I havent tested it yet.  Does it come up with any prompts informing you of the fact that an activeX control is being used.

The problems you encounter with this is the fact that is is activeX, thus an IE based solution only, and the fact that it does not work on Win2k machines (according to the article).  The most common message given by experts here regarding printing is that you cant, not with HTML.  If you need to control how something is printed, you need to convert the file to a document type where you do have certain control, such as PDF.
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
I would prefer converting it to a pdf format.
http://www.15seconds.com/issue/990902.htm
http://www.activepdf.com

hongjun
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 19

Expert Comment

by:webwoman
Comment Utility
Media or @print options in the HTML don't work with ANYTHING -- no browsers support them.

If it's critical that it print a certain way, make it a PDF. Other than that, it's an exercise in frustation.

If it needs to print landscape, tell the user that. Let them change the orientation -- then they know it's been changed.  
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
WebWoman, the MEDIA option of Style works just fine in all browsers above IE4, (except Mac, but who cares about Macs anyway);

<STYLE MEDIA="PRINT">
BODY {
     background-color:white;
     color:black;
     font-family : Arial, Helvetica, sans-serif;
     font-size : 10pt;
}
</STYLE>

<BODY>
This is a test print.<p>
<INPUT TYPE="BUTTON" VALUE="Print" ONCLICK="window.print()">

Unfortunately I have been playing with the controls and objects delivered and cannot get the ExecWB to print Landscape, and in IE5 the "DONTPROMPTUSER" call is not valid, it will still show the properties dialog.

Azra, the "wbp" script shown does use a Class object, but since I am no C++ or VB guru, I hope you can provide more input.
0
 
LVL 19

Expert Comment

by:webwoman
Comment Utility
Your body style is perfectly valid whether you use a media tag or not (and that's not the proper syntax from everything I've found). Your javascript doesn't use it either.

And if it worked, you'd be able to specify exactly the print settings you wanted, and they'd be applied. But that's not what's happening, is it?

According to the specs, it should be set as an alternative style, with the @media tag or that @page tag. The @media is a paged format... and according to everything I've found, the paged options and alternative styles aren't supported by anything.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
@media and @page are CSS2.

You need to try the MEDIA style like I posted, the BODY style is only applied to the PRINT queue, not the page.  With that thought, you could actually do this;

<STYLE MEDIA="PRINT">
BODY {
    background-color:white;
    color:black;
    font-family : Arial, Helvetica, sans-serif;
    font-size : 10pt;
}
</STYLE>
<STYLE>
BODY {
    background-color:black;
    color:white;
    font-family : sans-serif;
    font-size : 12px;
}
</STYLE>


<BODY>
This is a test print.<p>
<INPUT TYPE="BUTTON" VALUE="Print" ONCLICK="window.print()">
</BODY>

The page will be black with white font, the printed page will be white with black font.  The MEDIA tag is not browser friendly though, IE4> only.  No Netscape, (not sure about 6 though), and most certainly not Mac, (at least not IE4 for Mac).



0
 
LVL 19

Expert Comment

by:webwoman
Comment Utility
Please check here...
http://www.htmlhelp.com/reference/css/references.html
And note this line...
>>CSS2 provides numerous additions to CSS1, few of which are supported by browsers.
>>

Also check here...
http://richinstyle.com/bugs/table.html
And note the many things (almost everything relating to printing) that aren't supported or don't work.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Right, this works;

<STYLE MEDIA="PRINT">
BODY {
   background-color:white;
   color:black;
   font-family : Arial, Helvetica, sans-serif;
   font-size : 10pt;
}
</STYLE>

@MEDIA does not...
0
 
LVL 19

Expert Comment

by:webwoman
Comment Utility
But again... unless you have another style set for body (which isn't supported) why bother? You haven't set anything which is ONLY print oriented.
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 160 total points
Comment Utility
What?  This is my entire test page;

<HTML>
<HEAD>
<STYLE MEDIA="PRINT">
BODY {
     background-color:white;
     color:red;
     font-family : Arial, Helvetica, sans-serif;
     font-size : 10pt;
}
</STYLE>
</HEAD>
<BODY>
This is a test print.<p>
<INPUT TYPE="BUTTON" VALUE="Print" ONCLICK="window.print()">
</BODY>
</HTML>

In IE5 to a HP5mp, the page displays as default, sans-serif 10px, the print page is arial in 10 pt.

I don't follow you, what isn't supported besides the already mentioned @media tag?
0
 
LVL 33

Expert Comment

by:hongjun
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[points to mgfranz]

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

hongjun
EE Cleanup Volunteer
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now