Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Print SharePoint list in landscape orientation.

Posted on 2016-09-19
4
Medium Priority
?
100 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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 …

610 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