indianJsPdf.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE html>
  2. <html lang=ko>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Issue 369: Indian Currency Not Showing In Pdf Export</title>
  6. <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  7. <script type="text/javascript" src="../libs/FileSaver/FileSaver.min.js"></script>
  8. <script type="text/javascript" src="../libs/jsPDF/jspdf.umd.min.js"></script>
  9. <script type="text/javascript" src="../tableExport.js"></script>
  10. <style type="text/css">
  11. <!--
  12. caption {
  13. font-size: 1em;
  14. white-space: nowrap;
  15. text-align: left;
  16. }
  17. table {
  18. border-collapse: collapse;
  19. margin-top: 2em;
  20. }
  21. table > thead > tr > td,
  22. table > thead > tr > th {
  23. background-color: gray;
  24. border: 1px solid #efefef;
  25. color: white;
  26. padding: 0.2rem;
  27. }
  28. table > tbody > tr > td {
  29. border: 1px solid #999;
  30. padding: 0.2rem;
  31. }
  32. -->
  33. </style>
  34. <script type="text/javaScript">
  35. function doExport(selector, params) {
  36. var options = {
  37. tableName: 'Table name'
  38. };
  39. $.extend(true, options, params);
  40. $(selector).tableExport(options);
  41. }
  42. function doDocCreated(doc) {
  43. // In the next line replace <base64> with a base64 encoded font,
  44. // e.g Hind-Regular.ttf from Google Fonts family "Hind".
  45. // To do this, you need to upload your Indian font to a Base64 file encoder
  46. // and use its output in place of <base64> while preserving the apostrophes
  47. // so it would look similar like this:
  48. // const _fonts = "AAEAAAARAQAABAAQR0RFRkN6Q0gAAAMAAAAAxEdQT1Mmhse6AA ... kUBu/5FAbtAAAA=";
  49. const _fonts = "<base64>";
  50. if (_fonts === "<base64>") {
  51. alert ("Missing base64 encoded font, e.g Hind-Regular.ttf");
  52. return;
  53. }
  54. doc.addFileToVFS('Hind-Regular.ttf', _fonts);
  55. doc.addFont('Hind-Regular.ttf', 'Hind-Regular', 'normal');
  56. doc.setFont('Hind-Regular');
  57. doc.text(15, 120, 'नमस्ते'); // Example text output
  58. }
  59. </script>
  60. </head>
  61. <body>
  62. <p>
  63. <a href="#" onClick="doExport('#issue363',
  64. {type: 'pdf',
  65. jspdf: {orientation: 'l',
  66. onDocCreated: doDocCreated,
  67. autotable: {startY: 10,
  68. margin: {left: 10, top: 10},
  69. pageBreak: 'avoid'
  70. }
  71. }
  72. });">
  73. <img src='icons/pdf.png' alt="PDF" style="width:24px"> PDF (jsPDF)</a>
  74. </p>
  75. <table id="issue369" class="">
  76. <caption>Issue 369: Indian Currency Not Showing In Pdf Export</caption>
  77. <thead>
  78. <tr>
  79. <th>नमस्ते</th>
  80. <th>नमस्ते</th>
  81. <th>नमस्ते</th>
  82. </thead>
  83. <tbody>
  84. <tr>
  85. <td>नमस्ते</td><td>नमस्ते</td><td>₹500</td>
  86. </tr>
  87. <tr>
  88. <td>नमस्ते</td><td>नमस्ते</td><td>₹600</td>
  89. </tr>
  90. <tr>
  91. <td>नमस्ते</td><td>नमस्ते</td><td>₹8000</td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. </body>
  96. </html>