Solved

Print SharePoint list in landscape orientation.

Posted on 2016-09-19
4
26 Views
Last Modified: 2016-10-13
Hi I found the code listed below from the following website: Printer Friendly Button in Sharepoint.
The script works fine but I would like to know how can I make it print in landscape mode and reduce the font so the columns would fit on the page.

Code:
<script type="text/javascript" src="jQuery/jquery-1.3.2.min.js"></script>

<div>

<input id="printBtn" type="button" Value="Printer Friendly" alt="Print this page" style="margin-top:10px;margin-left:10px;"/>

</div>

<script>

$(document).ready(function()

{

var strlink="";

$("link[rel='stylesheet']").each(function()

{

strlink+="<link rel = 'stylesheet' href='"+$(this).attr('href')+"' type='text/css'/>";

});

$("#printBtn").click(function()

{

var htmlStr ="<html><head>"+strlink+"</head><body>"+$("#MSO_ContentTable").parent().html()+"</body></html>";

var PrintingWindow = window.open("about:blank","","toolbar,width=800,height=600,scrollbars,resizable,menubar");

PrintingWindow.document.open();
PrintingWindow.document.write(htmlStr);
PrintingWindow.document.close();
PrintingWindow.focus();
PrintingWindow.document.getElementById("printBtn").style.display="none";
PrintingWindow.print();
});

});

</script>

Open in new window

0
Comment
Question by:Daniel993
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 41805559
try including this style when u build html

<style type="text/css" media="print">
    @page { 
        size: landscape;
    }
    body { 
        writing-mode: tb-rl;
        font-size:smaller !important;
    }
</style>

Open in new window

0
 

Accepted Solution

by:
Daniel993 earned 0 total points
ID: 41805616
Thanks Gautham. Where should I include this? Currently I plugged the my code into the Content Editor web part in Sharepoint.
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 41805656
i meant here

var htmlStr ="<html><head>"+strlink+"</head><body>"+$("#MSO_ContentTable").parent().html()+"</body></html>";

Open in new window


u can add along with strlink
0
 

Author Closing Comment

by:Daniel993
ID: 41841646
yep worked
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

809 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