Created
September 20, 2020 13:48
-
-
Save robozavri/bca4a5c71b692f2dde37ab066cb58f69 to your computer and use it in GitHub Desktop.
php pdf converter with georgian font
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. download tcpdf https://github.com/tecnickcom/tcpdf | |
2. add georgian specific font | |
3. run script below | |
Add specific font from cmd | |
need run php this [TCPDF/tools/tcpdf_addfont.php] file drom cmd | |
example: | |
php tcpdf_addfont.php -i C:\OSPanel\domains\localhost\pdf-generators\dm-niko-nikoladze.ttf | |
or | |
php tcpdf_addfont.php -i "C:\Users\us store\Downloads\bpg-nino-mkhedruli-master\bpg-nino-mkhedruli-master\fonts\bpg-nino-mkhedruli-webfont.ttf" | |
SCRIPT: | |
// Include the main TCPDF library (search for installation path). | |
require_once('TCPDF/tcpdf.php'); | |
// create new PDF document | |
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); | |
// tgmodulimtavruli | |
// dmnikonikoladze | |
// bpgninomkhedruliwebfont | |
// $pdf->SetFont('tgmodulimtavruli'); | |
// $pdf->SetFont('dmnikonikoladze'); | |
$pdf->SetFont('bpgninomkhedruliwebfont','','25'); | |
// set document information | |
$pdf->SetCreator(PDF_CREATOR); | |
$pdf->SetAuthor('Our Code World'); | |
$pdf->SetTitle('Example Write Html'); | |
// set default header data | |
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING); | |
// set header and footer fonts | |
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); | |
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); | |
// set default monospaced font | |
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); | |
// set margins | |
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); | |
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER); | |
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER); | |
// set auto page breaks | |
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); | |
// set image scale factor | |
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); | |
// add a page | |
$pdf->AddPage(); | |
$html = '<h4>PDF Example</h4><br><p>ნიკოლოზას ტესტი რამე ქართული ტექსტია აბა სატესტო Welcome to the Jungle</p>'; | |
$pdf->writeHTML($html, true, false, true, false, ''); | |
// add a page | |
// $pdf->AddPage(); | |
// $html = '<h1>Hey</h1>'; | |
// output the HTML content | |
// $pdf->writeHTML($html, true, false, true, false, ''); | |
// reset pointer to the last page | |
// $pdf->lastPage(); | |
//Close and output PDF document | |
$pdf->Output('example_006.pdf', 'I'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment