INR Currency Symbol Add in fpdf - php

I want to add INR Currency Symbol in pdf file using fpdf. how to add INR Currency Symbol (Rupee) pdf file using fpdf.

See fpdf font dump documentation
http://www.fpdf.org/en/script/script4.php .
Here, No option to add rupee symbol (₹) so, u can use rupee symbol png image and integrate with fpdf.
$pdf->Image('rupee.png',8,10,-200);

Here is a way to print the rupee sign with FPDF:
Copy the cp1252.map file (located in the makefont directory) to cp1252+INR.map.
Open cp1252+INR.map in a text editor. Replace this line:
!A4 U+00A4 currency
with:
!A4 U+20B9 uni20B9
This will map the rupee sign at position 0xA4 (instead of the generic currency sign).
Choose a font that contains the rupee sign and use MakeFont() with the cp1252+INR encoding to convert it. Here I will use the Arial font that comes with Windows:
<?php
require('makefont/makefont.php');
MakeFont('C:\\Windows\\Fonts\\Arial.ttf', 'cp1252+INR');
?>
Copy the generated files (arial.php and arial.z) to the font directory.
Add the font in your script and use 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();
?>

I understand that this is pretty late but a simple solution to this issue would be to use tFPDF which is essentially an extension to FPDF. Using tFPDF, you can use the 'DejaVu Sans' font which supports the '₹' symbol along with most other currency symbols. This font comes in packed with the tFPDF as well, so you can literally plug it in and use it in your current system directly.
More information can be found here:
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();
?>
Cheers!!

Related

tFPDF - Hindi text spelling is incorrect in pdf

I want to write a hindi text in my pdf.
At first, I downloaded the ttf font file from google fonts
After that I included the ttf file inside font < unifont
After that, I added the fonts into my code:
<?php
require('tfpdf.php');
$pdf = new tFPDF();
$pdf->AddPage();
$pdf->AddFont('NotoSerifDevanagari-Regular','','NotoSerifDevanagari-Regular.ttf',true);
$pdf->SetFont('NotoSerifDevanagari-Regular','',10);
$pdf->Cell(40,10,'पूसीरे के रेसुब ने नाबालिगों समेत 12 लोगों को बचाया');
$pdf->Output();
?>
The resultant text in the pdf shows like this:
screenshot of my pdf
Here, as you can see the word नाबालिगों is incorrectly spelled. Why? How do I fix this?
see here :
tFPDF
This class is a modified version of FPDF that adds UTF-8 support
or this :
UFPDF
that adds UTF-8 support
but you could move to TCPDF

Jumbled Kannada fonts in pdf report using fpdf and php

Myself trying to generate pdf files in Kannada font using fpdf and php as,
require_once('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddFont('Baraha','','baraha.php');
$pdf->AddPage();
$pdf->SetFont('Baraha','',35);
$pdf->Write(10,' cheluva kannaDa nADu');
$pdf->Output();
Tried using baraha.ttf, tunga.ttf, lohit.ttf etc but every font gives jumbled output. Below is the output for baraha.ttf font for the above line. How to output correctly in Kannada?
In Braraha font:
In Lohit Font:
Followed both this and this tutorials.
EDIT: The correct Kannada sentence is ಚೆಲುವ ಕನ್ನಡ ನಾಡು for cheluva kannaDa nADu. Also please suggest other fonts for correct Kannada sentences. FYI, the same jumbled words are appearing in the case of tcpdf php library and pdfmake.js javascript library as well. So can anyone please suggest a best library (either javascript or php) for pdf generation.

TFPDF Lithuanian letters

I have a problem with lithuanian letters like ąčęėįšųūž. For that reason I use tfpdf and font DejaVu. When I get content from txt file, everything is fine but I give content just simply, then I get "????". Header charset is set utf-8.
ob_start();
require('../fpd/tfpdf.php');
$pdf = new tFPDF();
$pdf->AddPage();
// Add a Unicode font (uses UTF-8)
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
$pdf->SetFont('DejaVu','',10);
// Load a UTF-8 string from a file and print it
$txt = file_get_contents('../fpd/HelloWorld.txt');
$pdf->Write(8,$txt);
$pdf->Ln(10);
$txt1 = "ąčęėįšųž";
$pdf->Write(8,$txt1);
$pdf->Output('filename1.pdf', 'I');
ob_end_flush();
You do not need to set the header to UTF-8 but your editor have to be configured to use UTF-8. To verify that this is the issue, open the PHP file in e.g. Notepad++, click on "Encoding" and check the current encoding. You may convert it to UTF-8 (without BOM!!) in the same step and try again.

tcpdf truetype unicode font install

I cannot convert this font (TrueType Unicode) for use in tcpdf. I'm using UTF-8 encoding
https://dl.dropboxusercontent.com/u/14964998/chamberssansoffc.ttf
https://dl.dropboxusercontent.com/u/14964998/chamberssansoffcb.ttf
https://dl.dropboxusercontent.com/u/14964998/chamberssansoffcbi.ttf
https://dl.dropboxusercontent.com/u/14964998/chamberssansoffci.ttf
This font works fine on me website - renders Chinese, Polish, German, Romanian characters.
I would be grateful for help.
To see all UTF-8 encoding in tcpdf I will prefer use freeserif font.You can see a good example in tcpdf, example number 8.
Try this
$pdf->SetFont('freeserif', '', 12);
Now if you don't want to use freeserif, you can convert this font by tcpdf example by use this line.open tcpdf example folder, than open example __001, after 31 number line anywhere just past this code.Here make sure your path directory.Than run this code.After run go to font folder.You will get all your desire file.
$fontname = $pdf->addTTFfont('/wamp/www/tcpdf/arial/arialuni.ttf', 'TrueTypeUnicode', '', 32);
As far as i know you can`t use ttf directly but you can search for font converter tcpdf or use this tool: http://fonts.snm-portal.com/. Helped me.
It looks like you are trying to load the fonts remotely. That wont work with TCPDF because it needs to write the the font directory in order to create the pseudo-files for the PDF. Try adding them locally:
$fontname = $pdf->addTTFfont('/path-to-font/chamberssansoffc.ttf', 'TrueTypeUnicode', '', 32);
Also, you have to make sure that the font folder is writable on the server to allow TCPDF to create the pseudo-files.
Hope this helps!

How to generate multilingual content Pdf in PHP

I am using TCPDF to generate multilingual content PDF in PHP. I am using TCPDF and using font 'cid0jp' but It is forcing user to download language pack for adobe reader.
Is there any way to generate multilingual pdf without enforcing user to download any langauge pack?
Yes, there's a way. I just had the same issue. Why Adobe Reader is asking for the language pack i don't know.
But i know that the best way to create multilingual PDFs is to use the Arial Unicode MS-Font which is included in windows. That's the font with the most characters according to wikipedia!! But there's no Bold or Italics. You can buy a Arial Unicode Bold from http://www.linotype.com/en/817674/ArialUnicode-family.html#.
I use the Arial MS Unicode-Font with chinese, japanese, cyrilic. For western languages i use the normal Arial so i have italics and bold.
An other possibility is to use for each language a own font which is made for this language.
To make the Arial MS Unicode to work with tcpdf follow the steps on the answer of this Question: Creating PDFs using TCPDF that supports all languages especially CJK
I hope i could help...
Use html2pdf for multilingual.
I tried with this and it worked for me.I developed site for (English/Japanese)
Used font arialunicid0 for multilingual.
require_once('Classes/library/html2pdf.class.php');
//$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf = new HTML2PDF('P', 'A4', 'en', true, 'UTF-8');
$html2pdf->setDefaultFont('arialunicid0');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$filename = $filename .'_'.date('Ymd');
$html2pdf->Output($filename.'.pdf','D');
It download file with Japanese text.
Only problem I facing here with file name.
IF I pass Japanese character for file name it downloads file with blank name.

Categories