Solved

Print SharePoint list in landscape orientation.

Posted on 2016-09-19
4
14 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now