Solved

change page orientation/font size

Posted on 2001-08-14
18
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
  • +2
18 Comments
 
LVL 9

Expert Comment

by:msdixon
ID: 6384508
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
ID: 6384602
must be an activeX solution executing at the client
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6384721
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

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

Expert Comment

by:mgfranz
ID: 6384769
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
ID: 6384804
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
ID: 6384805
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
ID: 6385188
I would prefer converting it to a pdf format.
http://www.15seconds.com/issue/990902.htm
http://www.activepdf.com

hongjun
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6385452
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
ID: 6386600
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
ID: 6386940
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
ID: 6388431
@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
ID: 6389902
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
ID: 6390898
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
ID: 6392121
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
ID: 6392188
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
ID: 8672574
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can I print examples of all of my installed fonts? 6 54
Set time on Session (ASP) 14 35
ASP get fieds value 2 38
ms sql string field to asp variable as number 5 29
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 was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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