2

My web page needs to print some data. and I am using "JS Print Setup" add-on (Mozilla fire fox) to print. Here I want to print only a particular content from my web page. Can anyone help me. My code is

function test2() {
   
   
   jsPrintSetup.setPaperSizeUnit(jsPrintSetup.kPaperSizeMillimeters);
   jsPrintSetup.definePaperSize(44, 44, "na_label", 'na_label_51x25mm', "The Quarry", "100", "100", jsPrintSetup.kPaperSizeMillimeters);
   jsPrintSetup.setPaperSizeData(44);
   jsPrintSetup.setOption('shrinkToFit', true);
   
   
  jsPrintSetup.clearSilentPrint();  
  jsPrintSetup.setSilentPrint(1); 

  jsPrintSetup.setOption('orientation', jsPrintSetup.kPortraitOrientation);
  // Reduce margins
  jsPrintSetup.setOption('unwriteableMarginTop', 0);
  jsPrintSetup.setOption('unwriteableMarginLeft', 0);
  jsPrintSetup.setOption('unwriteableMarginBottom', 0);
  jsPrintSetup.setOption('unwriteableMarginRight', 0);

  jsPrintSetup.setOption('marginTop',0);
  jsPrintSetup.setOption('marginBottom',0);
  jsPrintSetup.setOption('marginLeft',10);
  jsPrintSetup.setOption('marginRight',0);

  // Empty headers & footers
  jsPrintSetup.setOption('headerStrLeft', '');
  jsPrintSetup.setOption('headerStrCenter', '');
  jsPrintSetup.setOption('headerStrRight', '');
  jsPrintSetup.setOption('footerStrLeft', '');
  jsPrintSetup.setOption('footerStrCenter', '');
  jsPrintSetup.setOption('footerStrRight', '');

  jsPrintSetup.setOption('printRange', jsPrintSetup.kRangeSpecifiedPageRange);
  jsPrintSetup.setOption('startPageRange', '<div id="testfff">');
  jsPrintSetup.setOption('endPageRange', '</div>');
  
  jsPrintSetup.print();
  
}
<a href="javascript: test2();">Test1</a>

<div id="testfff"> 
   <table width="50mm">
      <tr>
         <th>Name</th>
         <th>Mark</th>
      </tr>
      <tr>
         <td>Shihab</td>
         <td>25</td>
      </tr>
      <tr>
         <td>Shihab</td>
         <td>25</td>
      </tr>
      <tr>
         <td>Shihab</td>
         <td>25</td>
      </tr>
      <tr>
         <td>Shihab</td>
         <td>25</td>
      </tr>
   </table>   
</div>
Sam
  • 131
  • 1
  • 12

0 Answers0