473,517 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

printing page in landscape

19 New Member
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 14101
CroCrew
564 Recognized Expert Contributor
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
gotonagle
19 New Member
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
gotonagle
19 New Member
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 Recognized Expert Contributor
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
gotonagle
19 New Member
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
2982
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 of the printing, I arranged the graphic elements on the page the way it should be. When I got to printing text, it went across the page, not down as...
4
4834
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 selected. For example, if I were to have 5 pages with every second page printing, I would get the following results: Page 1 = Print OK Page 2 =...
3
10568
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 myDocument As PrintDocument = PreparePrintDocument() Dim myPaperSize As PaperSize Dim iSizeCount As Integer Dim dlgPrint As New PrintDialog
6
19603
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, etc) This is because it's a data driven site where space is at a premium and we'd rather discourage use of back, stop and refresh. The problem...
5
10072
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 System.Drawing; using System.Drawing.Printing; using System.IO;
5
6826
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. I do not want to use a dialog to do it and this appears the only way you can do it. I just need it to spit out the print in landscape orientation. ...
3
31789
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 Printing.PaperSize("sdfgsfdg", 850, 1100)
8
2390
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 "InvalidPrinterException was unhandled" error. The error happens in the third line below. The details of the error are below my signature. Help? ...
2
9933
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 printer settings to print. I wanted the print preview to appear the same for all users (i.e. a default page size of 8.5x14 (legal) and portrait...
6
5573
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 line in css files, <style type="text/css"> <!-- @page { size: landscape; } -->
0
7287
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7422
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7150
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5725
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1629
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.