Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

I am using Java Script to print. It is ...
C#
function printPartOfPage(elementId)
    {
     var printContent = document.getElementById(elementId);
     var windowUrl = 'about:blank';
     var uniqueName = new Date();
     var windowName = 'Print' + uniqueName.getTime();
     var printWindow = window.open(windowUrl, windowName,
    'left=0,top=0,width=725,height=950');

     printWindow.document.write(printContent.innerHTML);
     printWindow.document.close();
     printWindow.focus();
     printWindow.print();
     printWindow.close();
    }

I require to set Top Margin. Please suggest how do I set margin.
Posted
Comments
Maciej Los 1-Mar-14 5:54am    
Why to use java, if you're programming in C@ for ASP.NET?

Please, read my comment to the question.

I would suggest to use PrintDocument[^] class. It is more flexible and enable to set PrinterSettings[^] ;)
 
Share this answer
 
Comments
Marc Gabrie 1-Mar-14 15:45pm    
He's using ASP.NET not Windows Forms. If you use PrintDocument in ASP.NET, you'll be able to print at server side only.
You have to use CSS for adding any margin for printing purposes.
 
Share this answer
 
Comments
LebneizTech 5-Mar-14 8:13am    
Please suggest CSS.
Marc Gabrie 6-Mar-14 7:47am    
http://stackoverflow.com/questions/1542320/margin-while-printing-html-page

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900