印度卢比货币符号 添加 fpdf



我想使用 fpdf 在 pdf 文件中添加 INR 货币符号。如何使用 fpdf 添加 INR 货币符号 (卢比( PDF 文件。

请参阅 fpdf 字体转储文档

http://www.fpdf.org/en/script/script4.php .

在这里,没有添加卢比符号(₹(的选项,因此,您可以使用卢比符号png图像并与fpdf集成。

$pdf->图像("卢比.png",8,10,-200(;

这是一种使用 FPDF 打印卢比符号的方法:

  • 将 cp1252.map 文件(位于 makefont 目录中(复制到 cp1252+INR.map。

  • 在文本编辑器中打开 cp1252+INR.map。替换此行:

!A4 U+00A4 currency

跟:

!A4 U+20B9 uni20B9

这将在位置 0xA4 映射卢比符号(而不是通用货币符号(。

  • 选择包含卢比符号的字体,并使用MakeFont()cp1252+INR编码进行转换。在这里,我将使用Windows附带的Arial字体:
<?php
require('makefont/makefont.php');
MakeFont('C:\Windows\Fonts\Arial.ttf', 'cp1252+INR');
?>

将生成的文件(arial.php 和 arial.z(复制到字体目录。

  • 在脚本中添加字体并使用chr(0xA4)
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddFont('Arial', '', 'arial.php');
$pdf->AddPage();
$pdf->SetFont('Arial', '', 20);
$pdf->Write(5, 'Rupee sign: '.chr(0xA4));
$pdf->Output();
?>

我知道这已经很晚了,但解决这个问题的简单方法是使用 tFPDF,它本质上是 FPDF 的扩展。使用tFPDF,您可以使用"DejaVu Sans"字体,该字体支持"₹"符号以及大多数其他货币符号。这种字体也包含在tFPDF中,因此您可以直接将其插入并直接在当前系统中使用它。 更多信息可以在这里找到:

http://www.fpdf.org/?go=script&id=92

<?php
// Optionally define the filesystem path to your system fonts
// otherwise tFPDF will use [path to tFPDF]/font/unifont/ directory
// define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/");
require('tfpdf.php');
$pdf = new tFPDF();
$pdf->AddPage();
// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',14);
// Load a UTF-8 string from a file and print it
$txt = file_get_contents('HelloWorld.txt');
$pdf->Write(8,$txt);
// Select a standard font (uses windows-1252)
$pdf->SetFont('Arial','',14);
$pdf->Ln(10);
$pdf->Write(5,'The file size of this PDF is only 13 KB.');
$pdf->Output();
?>

干杯!!

最新更新