2016-07-28 1 views
0

Ceci est juste un simple fichier html en utilisant pdfmake. Je clique sur un bouton, puis ouvre un fichier pdf. utilisant:comment convertir html en pdf avec une police ou une langue spécifique en utilisant pdfmake

pdfMake.createPdf(docDefinition).open(); 

c'est ok, mais maintenant je veux voir une langue spécifique (ex: Bangla) dans mon pdfpage. comment c'est possible . aidez-moi ou suggérez-moi

partie d'en-tête:

<head> 
    <!-- <meta charset="utf-8" />--> 
    <meta http-equiv="Content-Type" content="text/html" meta charset="utf-8" /> 
    <title>html to pdf</title> 
    <link href="css/main.css" rel="stylesheet"> 
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> 
    <script src='pdfmake/build/pdfmake.min.js'></script> 
    <script src='pdfmake/build/vfs_fonts.js'></script> 
    <script src='build/pdfmake.min.js'></script> 
    <script src='build/vfs_fonts.js'></script> 

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous"> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script> 

</head> 
partie du corps

:

<body> 

    <h1>Hello World</h1> 
    <div class="btn-group"> 
     <div class="btn btn-success buttin_click_1" type="button">download</div> 
     <div class="btn btn-danger button_click_2" type="button">open</div> 
    </div> 

</body> 

Script:

<script> 
    $(document).ready(function() { 
     var docDefinition = { 
      content: 'This is an sample PDF printed with pdfMake ami ' 
     }; 

     $('.buttin_click_1').click(function() { 
      console.log('btn 1 clicked'); 
      pdfMake.createPdf(docDefinition).open(); 
     }); 

     $('.button_click_2').click(function() { 
      console.log('btn 2 clicked'); 
     }); 
    }); 
</script> 

Merci.

Répondre

0
  1. Importez la police dans pdfMake.
  2. mettre à jour ensuite les vfs_fonts.js comme décrit github
  3. pdfMake.fonts Assigner dans votre javascript
 

    $(document).ready(function() { 
     pdfMake.fonts = { 
      'SolaimanLipi': { 
       normal: 'SolaimanLipi-Regular.ttf', 
       bold: 'SolaimanLipi-Medium.ttf' 
      } 
     }; 
     var docDefinition = { 
      content: 'হ্যালো', 
      defaultStyle:{ 
       font: 'SolaimanLipi' 
      } 
     }; 

     $('.buttin_click_1').click(function() { 
      console.log('btn 1 clicked'); 
      pdfMake.createPdf(docDefinition).open(); 
     }); 

     $('.button_click_2').click(function() { 
      console.log('btn 2 clicked'); 
     }); 
    });