473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

printing page in landscape

hi all
i have one page that generates a report (basically a table ) in ASP.i have a button that prints that page using window.print(). now i want to print that page in landscape mode (by default its printing in potrait mode). i dont want to ask user to change orientation from print window.
pls let me know if we can have any such javascript or server script that either change the printer setting or make the page or div to be printed as landscape.
thanks in advance.

Rahul
Jan 24 '08 #1
5 14075
CroCrew
564 Expert 512MB
Hello gotonagle,

Here is an example that you can try out.

Hope this helps~

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>Example</title>
  4.         <style type="text/css" media="print">
  5.             div.PageBreak
  6.             {
  7.                 page-break-after:always
  8.             }
  9.  
  10.             div.page
  11.             { 
  12.                 writing-mode: tb-rl;
  13.                 height: 80%;
  14.                 margin: 10% 0%;
  15.             }
  16.  
  17.             div.page table 
  18.             {
  19.                 margin-right: 80pt;
  20.                 filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=1);
  21.             }
  22.         </style>
  23.     </head>
  24.     <body>
  25.         <p><h3>Print this!!</h3></p>
  26.         Page one's orientation will be printed in portrait.
  27.         <!--Page Break--> <div class="PageBreak"> </div> <!--Page Break-->
  28.  
  29.         <div class="page">
  30.             Page two's orientation will be printed in landscape.
  31.             <table border="1">
  32.                 <tr><td>A1</td><td>A2</td><td>A3</td><td>A4</td><td>A5</td></tr>
  33.                 <tr><td>B1</td><td>B2</td><td>B3</td><td>B4</td><td>B5</td></tr>
  34.             </table>
  35.         </div>
  36.         <!--Page Break--> <div class="PageBreak"> </div> <!--Page Break-->
  37.  
  38.         Page three's orientation will be printed in portrait.
  39.     </body>
  40. </html>
  41.  
  42.  
  43.  
Jan 25 '08 #2
Hi CroCrew,
Thanks for ur help. problem is solved in similar code but in little different way.
i m using it as here
Expand|Select|Wrap|Line Numbers
  1. table.landscape{
  2. filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=1);
  3. }
  4.  
  5. <TABLE width=98% align=center class="landscape" >
  6. <tr>
  7. <td>
  8. <table>
  9. <table>
  10. </td>
  11. </tr>
  12. <tr>
  13. </tr>
  14. <tr>
  15. </tr>
  16. </TABLE>
  17.  
its because i have some nested tables also and if i rotate eveytable it will just give some 'horrible' output..:)

but now my problem is that when i print this page it gives me header-footer as per the portait mode. i wanted them to either come in landscape mode or removed. and this header footers are browsers setting. is there any script to remove this??
pls let me know..
Thanks again

Rahul.
Jan 28 '08 #3
also i am trying to use this script now for removing header

Expand|Select|Wrap|Line Numbers
  1.  
  2.       Dim WSHShell
  3.       Dim myHeader
  4.       Dim myFooter
  5.       Set WSHShell = CreateObject("WScript.Shell")
  6.       myHeader = WSHShell.RegRead("HKCU\Software\Microsoft\Internet Explorer\PageSetup\header")
  7.       myFooter = WSHShell.RegRead("HKCU\Software\Microsoft\Internet Explorer\PageSetup\footer")
  8.  
  9.       WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\header", ""
  10.       WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\footer", ""
  11.  
  12.       Sub ResetHeader()
  13.         Dim WSHShell
  14.         Set WSHShell = CreateObject("WScript.Shell")
  15.         WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\header", myHeader
  16.         WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\footer", myFooter
  17.       End Sub
  18.  
  19.  
  20.  
but i am getting an error saying

Error Type:
WshShell.RegRead (0x80070002)
Invalid root in registry key "HKCU\Software\Microsoft\Internet Explorer\PageSetup\header".

can anyone pls help...............

thanks
Jan 28 '08 #4
CroCrew
564 Expert 512MB
Well, if your target costumers are running Microsoft's Internet Explorer browser then you could try ScriptX from MeadCo: http://www.meadroid.com/scriptx/

The free version which doesn't have all the bells and whistles of the pay for version does still support printing orientation and header & footer settings and is freely distributable.

I will keep on looking...
Jan 28 '08 #5
thanks for your reply friend.
we think thats like overkilling to do like this. to just omit a header (which do not cause any harm) i m not going to do tjhis much.
and also my TL told me better to leave it as it is.
so now i am not worried about that now..
but YES..any cheaper solution u may have would be helpful for me.
Thanks again CrowCrew.

grateful to you
Rahul.
Jan 29 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Darcy Kahle | last post by:
I am trying to do some advanced printing in python using the win32ui module, and have run into an issue. I need to print a page landscape. As I could not determine how to specify the orientation...
4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
3
by: MarcJ | last post by:
Hello, I can't seem to get printing to landscape working. Here is some of the code I've tried. '--------------------------------------------------------------------------------- Dim...
6
by: Biguana | last post by:
Hi, Just wondering if anyone can help here. We have a site where most of the site opens in a window with no toolbars or menubar: window.open('mypage.aspx','self','toolbar=0, menubar=0, etc,...
5
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using...
5
by: cpopham | last post by:
I tried posting earlier and it never showed up.. I have a simple program to print a text file. I need to know how to change the page settings to landscape if it is not already in ladnscape mode. ...
3
by: D Witherspoon | last post by:
No matter what I do the default paper size is always either A3 or 11 by 8.5 .. Here is the code. Dim dlg As DialogResult pd.DocumentName = "Weld Image" Dim pkPaperSize As New...
8
by: Rick Lederman | last post by:
I am using a PrintDocument and PrintDialog to print. The first time that I print it works, but when I try to print a second time without exiting the entire program I get an...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
6
by: farukcse | last post by:
Dear sir, I have trouble with printing page with landscape. I am using java script to print the page. as well as I have set css file to print landscape but it is not working. I have used these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.