Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6

    Question Bangla (Unicode) font not rendering correctly in tcpdf


    I am facing a problem with generating pdf in php by using TCPDF library. I need to show the bangla font correctly. I tried to add some bangla font(i.e. SolaimanLipi.ttf, SutonnyOMJ.ttf, Siyamrupali.ttf, Nikosh.ttf and so on). I can see the bangla font on pdf but the font is not display correctly. Its misplaced the word.

    By adding this font I see the on the /fonts/ directory there successfully created 3 file “solaimanlipi.ctg.z”,”solaimanlipi.php” and “solaimanlipi.z”. As well as I can see the bangla font on pdf, but this font is misplaced/scattered. I am attaching a picture what I actually see.

    This is how it should look (From browser screenshot):

    6xglF.png


    Here is the code to show above result:

    Code:
        <?php
    	$strData = file_get_contents('./data3.txt');
        ?>
        <html lang="en" dir="ltr">
    	<head>
    		<meta charset="utf-8" />
    		<style>
            @font-face
            {
                font-family: myUniFont;
                src: url(./SolaimanLipi_22-02-2012.ttf);
            }
            </style>
    	</head>
    	<body>
    		<span style="font-family: myUniFont;"><?php echo $strData; ?></span>
    	</body>
        </html>
    I use below code to use that very same font in my pdf:

    Code:
        $strBNFont = TCPDF_FONTS::addTTFfont('./SolaimanLipi_22-02-2012.ttf', 'TrueTypeUnicode', '', 32);
        $pdf->SetFont($strBNFont, '', 8, '', 'false');
    And It is how it look like in PDF:

    yQ7E6.png


    Please advice me how can I display the bangla font correctly.

    thanks in advance
    best regards
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6
    any help please?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,473
    Rep Power
    653
    First please enclose your code in the proper tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    As for your specific problem, it may not be on the server side. The fonts installed on your http server have nothing to do with the fonts available to the browser on the client side. You need to verify the fonts on your client.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6
    thanks for your reply
    1. sir, i think i use proper tag for my code? can you tell which one is wrong so i can correct?
    2. sir, its not nothing with client font, because i embedded the font in pdf..

    thanks again for your reply

    best regards
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,473
    Rep Power
    653
    1. Read the sticky as I said. It explains it quite clearly.
    2. So you are trying to create a PDF file on the server then wanting to upload it to the client? Please clarify as I do not see any PHP code that creates the PDF file nor where you are uploading it to the client.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6

    Lightbulb


    i have attached (now) the zip file that have all the necessary file to check...
    Attached Files
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,473
    Rep Power
    653
    That doesn't answer my question as to how you are generating the PDF and what you want to do with it. Just post the code as instructed by the sticky. I don't download files from unknown sources.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6
    here is the code as you asked for:

    PHP Code:
    <?php
    // Include the main TCPDF library (search for installation path).
    require_once('./../Classes/tcpdf/config/tcpdf_config.php');
    require_once(
    './../Classes/tcpdf/tcpdf.php');

    // create new PDF document
    $pdf = new  TCPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue'UTF-8'false);

    // remove default header/footer
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);

    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

    // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT15PDF_MARGIN_RIGHT);

    // set auto page breaks
    $pdf->SetAutoPageBreak(TRUE15);

    // set image scale factor
    //$pdf->setImageScale(1);

    // add a page
    $pdf->AddPage();

    $strBNFont TCPDF_FONTS::addTTFfont('./SolaimanLipi_22-02-2012.ttf''TrueTypeUnicode'''32);
    $pdf->SetFont($strBNFont''8'''true');

    //$pdf->SetFont('times', '', 8);

    $txt '; স্কাউট হওয়া ভারি মজা ;   ; তোমাদের  জন্য মুক্তিযুদ্ধের গল্প ;';
    $pdf->Write(0$txt''0'C'true0falsefalse0);

    //Close and output PDF document
    $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' time() . '.pdf''F');

    echo 
    'done';
    thanks for your reply

    best regards
  16. #9
  17. Not An Expert
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2015
    Posts
    404
    Rep Power
    4
    Hello zakir_szh,

    I don't think you've read our rules or stickies because, as gw1500se indicated, you are using the wrong code tags. For PHP code, we have special [PHP] tags which make the code easier for our users to read.

    I have corrected your tags in the above post. Please continue to use [PHP] tags for PHP code, and [Code] tags for other types of code.

    Thanks!
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6
    Originally Posted by markroberts
    Hello zakir_szh,

    I don't think you've read our rules or stickies because, as gw1500se indicated, you are using the wrong code tags. For PHP code, we have special [PHP] tags which make the code easier for our users to read.

    I have corrected your tags in the above post. Please continue to use [PHP] tags for PHP code, and [Code] tags for other types of code.

    Thanks!
    thanks a lot for your reply and i am sorry as he didn't mentioned that as you did, i was just in hurry as i am very deadly stuck with that issue. and i am very familiar with [code] tags.

    once again, thanks for the clarification..

    best regards

    Comments on this post

    • Will-O-The-Wisp agrees : No worries - using the right code tags just makes it easier for everyone :)
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,473
    Rep Power
    653
    Rather than looking at what the browser shows, does the PDF file itself look correct? Also, since you don't keep track of the name when you write the file, how do you access it later to output it to the browser?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6
    Originally Posted by gw1500se
    Rather than looking at what the browser shows, does the PDF file itself look correct? Also, since you don't keep track of the name when you write the file, how do you access it later to output it to the browser?
    Nope sir, pdf isn't look correct

    this is how it is shows on browser:
    TCPDF-1.png


    and this is how it is shows in pdf:

    TCPDF-3.png


    hope that makes sense

    best regards
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6
    Originally Posted by markroberts
    Hello zakir_szh,

    I don't think you've read our rules or stickies because, as gw1500se indicated, you are using the wrong code tags. For PHP code, we have special [PHP] tags which make the code easier for our users to read.

    I have corrected your tags in the above post. Please continue to use [PHP] tags for PHP code, and [Code] tags for other types of code.

    Thanks!

    sir, i am trying to attach image in my post (show the image)

    but it not showing the image instead its only shows the image file name

    can you help please?
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,473
    Rep Power
    653
    The 2nd image looks the same as the one you said was correct in your first post. The first image is just missing the title and borders. You need to better explain what is wrong with each image.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    66
    Rep Power
    6

    Exclamation


    Originally Posted by gw1500se
    The 2nd image looks the same as the one you said was correct in your first post. The first image is just missing the title and borders. You need to better explain what is wrong with each image.
    sir, i am very sorry and i do understand as that image shows different language than yours (English). But of course both image is not the same. (just ignore title and border) the text is important. does it look same in both image? nope it is not sir..

    our language is complex Unicode character.. and in 2nd image (the one with title and border) it gets broken. for example..

    in our language we use joint character.. (like 3-6 character/key makes one character)

    for example:
    r+g+Shift v make (ignore the + sign) one joint character where in english it is 3 character right?

    is that makes sense?

    below is the character i am talking about (it shows same/correct in browser too):
    Single Char.png


    and below is how it is get broken in pdf output
    Broken Character.png


    thanks again for your so much kindness to help me out

    best regards
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo