Solved

Print SharePoint list in landscape orientation.

Posted on 2016-09-19
4
56 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

724 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