How to use printer codes in html/landscape printing using JS

Posted by arvind.thakur8 on 19-Oct-2011 07:38


   Hi All,

                From last couple of months I am trying to set printer orientation to landscape using javascript or css but haven't got success.I have tried so many things

         like @ page { size: landscape; } or writing-mode:tb-rl; in css but nothing works for me.

        Recently I found printer command language concept in which we can pass the escape sequence like ~&l1O is used for landscape.I also tried following simple stuff in

        progress which is working.

      OUTPUT TO "e:\test.txt".

       define var comp-beg as char format "x(30)".

       comp-beg = "~033&k2G~033&l1O~033&l5.45C~033&k2S".

       put control comp-beg.

       display "test" .

       OUTPUT CLOSE.

      But I don't know how to use these printer control codes in HTML, bcoz in my application we are using HTML, Javascript and CSS to do all front end stuff and i want to use this

     in HTML.

     Otherwise it will be good if any one knows how to do this in Javascript or CSS. Currently we are using IE9 browser for our web application.

     Thanks & regards,

     Arvind Thakur

All Replies

Posted by Admin on 20-Oct-2011 02:58

PCL won't work as youare going to print from browser on the client side. If you plan to use only IE then this might work for you... http://forums.asp.net/t/1302358.aspx/1, the image rotation seems to work on print preview (didn't try it on paper though).

imho, it will be better to switch to some document format that allows more control over page format than html (like pdf, word).

Posted by coop on 02-Dec-2011 16:39

I went through this also and determined that it is not possible to control print settings from a web browser.  This is somewhat by design that a browser (html, css, javascript...) should not be able to control or access your computer for security reasons.  About the best you can do is provide instructions to the user on how to go to the browser menu, page setup and manually change it to landscape themselves.

This thread is closed