javascript - How Can i set the fontsize time of print - Stack Overflow

for print datatable i have js code is :<script type="textjavascript">function data(div

for print datatable i have js code is :

<script type="text/javascript">
  function data(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>

But in case it generate the print option and save the file but because of scrool in datatbale its not printing plete data

My anchor is given below:

for print datatable i have js code is :

<script type="text/javascript">
  function data(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>

But in case it generate the print option and save the file but because of scrool in datatbale its not printing plete data

My anchor is given below:

Share edited Jan 29, 2018 at 7:17 Apoorva asked Jan 29, 2018 at 6:13 ApoorvaApoorva 812 silver badges8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

The best way is to make use of CSS3 media query for it.

@media print{
   body{
       font-size:12px;
       font-family:"Times New Roman";
   }
}

for more details about media query check out MDN link.


media query helps browser to select proper style depending on the situation. The style gets overridden as below.

  1. in-line style
  2. selector (in media query)
  3. selector (not in media query)

If you are trying to override some selector, add the same in media query, with changed properties. Browsers then will select the styles defined in appropriate query.

If you have the style in-line, then one way to solve is using !important tag. It is generally not preferred to use the important tag.

For the print design include separate css

<link rel="stylesheet" type="text/css" href="https://www.example./css/print.css" media="print" />

for edit print layout using inspect element Open inspect element >>> More Tool >>> click on Rendering

you will see Emulate CSS media drop down select print

Now edit css and check the result.

Note: I have tested it in chrome

Thanks

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744862773a4597800.html

相关推荐

  • javascript - How Can i set the fontsize time of print - Stack Overflow

    for print datatable i have js code is :<script type="textjavascript">function data(div

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信