How to Wrap Cell's Content in PDF | PHP FPDF Tutorial #7

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • EDIT : I have made a new tutorial about PDF table with cell wrapping abilities using multicell which is more efficient than this one. I recommend you to use that method instead. Please watch it here : • PDF Table with text wr...
    welcome to the seventh chapter of PHP FPDF tutorial series.
    in this chapter, i'm about to demonstrate how to handle overflowing text in PDF cells.
    we will utilize and also explain GetStringWidth, SetFontSize and MultiCell method in this tutorial.
    this time i'm about to explain two method of text wrapping.
    font shrinking and multi cell.
    font shrinking handle overflowing text by shrinking the font size until it fits in the cell.
    this is the most simple method, this method keeps the height of every row equal.
    but the downside is, it's only limited to text which is slightly longer than the cell.
    longer than that, the text will become unreadable because it's too small.
    compared to font shrinking, multi cell allows longer text without loss of readability.
    but it's more complex and require more calculation.
    Source code : bit.ly/3hYdT0F
    More tutorial on this series : goo.gl/TNqTN4 (PHP PDF Tutorial Series)

ความคิดเห็น • 139

  • @ukalistaxd9464
    @ukalistaxd9464 10 หลายเดือนก่อน +1

    love that you provide visual explanation on how the logic works

  • @Sloarot
    @Sloarot 2 ปีที่แล้ว +1

    It took me a while, but thanks to your fabulous explanation I think I've managed. thank you so much for this explanation. Unbelievable that such an important part is not explained on the website of free pdf itself!

  • @arjuntr7985
    @arjuntr7985 4 หลายเดือนก่อน

    Thank you. I was able to tackle the same problem in python Fpdf.

  • @eldjennemo2122
    @eldjennemo2122 4 ปีที่แล้ว +1

    Hi,
    This tutorial is really interesting and, above all, the explanations are extremely clear.
    No doubt I gonna use this method in my web applications developpement.
    Thx a lot !

  • @houarirechache9147
    @houarirechache9147 ปีที่แล้ว

    thanks so much you solved a big problem i had

  • @reynaldiarytumanan1199
    @reynaldiarytumanan1199 ปีที่แล้ว

    I'm having trouble in multicell when the text contains enter, causing the wrap text is not complete. What's the solution to this problem? thank you

  • @kundukandanfamily
    @kundukandanfamily หลายเดือนก่อน

    thanks, this video was really helpful

  • @riyazuddinsh
    @riyazuddinsh 6 ปีที่แล้ว

    I will never gonna unsubscribe your channel man. You are the best bro. But I am having 10 columns in which two column name and email needs to fit in the column.

  • @Desdroyer24
    @Desdroyer24 5 ปีที่แล้ว +1

    is there a way to make this for multiple rows? I mean, you make this only for the row "item[2]" but almost always there is more than one row that overflows

    • @josepolo9585
      @josepolo9585 ปีที่แล้ว

      hola, como lo conseguiste?

  • @vesselincohen437
    @vesselincohen437 6 ปีที่แล้ว

    Thank you for all good tutorials you made! I learned a lot from you!

  • @rogermezz
    @rogermezz 6 ปีที่แล้ว

    hi, can you help me. I need to export two tables in the same report but when i execute the while the second table is insert in down cells, how i make to insert next to the first table?

  • @hikmetgumus2821
    @hikmetgumus2821 3 ปีที่แล้ว

    Hello, how can we adjust the table size? I am trying to make two tables on the page and make it one subtable. Thank you

  • @sachinadi88
    @sachinadi88 4 ปีที่แล้ว

    Thanks a lot... Much needed and helpful

  • @tmssweb4683
    @tmssweb4683 7 ปีที่แล้ว

    Thank you very much. I am waiting with eagerness for this tutorial. can you help me about show database image in cell in FPDF.

  • @debashishmishra9309
    @debashishmishra9309 6 ปีที่แล้ว

    Your Tutorials are Awesome!!

  • @rozaimizamahri9604
    @rozaimizamahri9604 6 ปีที่แล้ว +1

    Hi,
    How to make other column response the cellheight like the column 2 does ? your code only works for single column only.
    Appreciate if you can help us .
    Thanks

    • @rozaimizamahri9604
      @rozaimizamahri9604 6 ปีที่แล้ว

      Thank you for the reply. I'll give it a try :)

    • @rozaimizamahri9604
      @rozaimizamahri9604 6 ปีที่แล้ว

      Hi, I manage to wrap the text inside the cell table using this references www.fpdf.org/en/script/ex3.pdf,
      But I have two (2) problems which is :
      1. How to align specific column
      2. How to create side by side table with database value
      Here's the link for the question
      stackoverflow.com/questions/52402231/fpdf-multicell-how-to-align-specific-cell-in-fpdf-using-php
      Can you help me out at solve the question number 1 ? I posted the question on stackoverflow. Hope you can view and help me . Thanks

    • @rozaimizamahri9604
      @rozaimizamahri9604 6 ปีที่แล้ว

      It's okay. :) . Already found the solution using TCPDF .Thanks btw . Cheers

  • @aguilardiego84
    @aguilardiego84 3 ปีที่แล้ว +1

    Gracias, funcionó muy bien!

  • @suleimangaitho2686
    @suleimangaitho2686 6 ปีที่แล้ว

    hello,this is pretty useful,could i get a copy of the code? Thanks man.

  • @chendraoe2710
    @chendraoe2710 2 ปีที่แล้ว

    Thank you so much !

  • @ahsankhanrokhri1489
    @ahsankhanrokhri1489 4 ปีที่แล้ว

    Good and clear information. JizakAllah..

  • @shameemn
    @shameemn 6 ปีที่แล้ว

    Hi, This was very helpful.. just something I found useful in case of MultiCell if the input text has new line characters then we will not get the exact line numbers hence it will be good to also check for if(strstr($tmpString, PHP_EOL)) $continueWhile = false; and include $continueWhile in the $tmpString while loop.

    • @shameemn
      @shameemn 6 ปีที่แล้ว

      You are most welcome and your video's have been really helpful. Please continue the great stuff!

    • @vhorhat17
      @vhorhat17 6 ปีที่แล้ว

      Where do you put this code?

    • @shameemn
      @shameemn 6 ปีที่แล้ว

      I used it something like this...
      $continueWhile = true;
      while($startChar < $textLength){
      while(($pdf->GetStringWidth($tmpString) < ($cellWidth-$errMargin) && ($startChar+$maxChar) < $textLength) && $continueWhile){
      $maxChar++;
      $tmpString=substr($inputString, $startChar, $maxChar);
      if(strstr($tmpString, PHP_EOL)){
      $continueWhile = false;
      }
      }
      $continueWhile = true;
      $startChar += $maxChar;
      array_push($textArray, $tmpString);
      $maxChar = 0;
      $tmpString = "";
      }
      $line = count($textArray);

  • @F3RC4O
    @F3RC4O 2 ปีที่แล้ว

    Pues me funcionó, bastante útil.

  • @carriep7812
    @carriep7812 4 ปีที่แล้ว

    I have ingested a wealth of knowledge form these Gemul Channel videos - so thank you, but this one was a miss. I was not able to get this to work, sadly.

  • @pmrakibulhasan635
    @pmrakibulhasan635 3 ปีที่แล้ว

    thank you. amazing tutorial and well documented

    • @GemaCode
      @GemaCode  3 ปีที่แล้ว +1

      Thank you very much for the feedback. :)

  • @WTFMoment88
    @WTFMoment88 9 หลายเดือนก่อน

    how to use this method to my profile data fetch form mysql

  • @digadget
    @digadget 5 ปีที่แล้ว

    there is possible to wrapping image on cell ?

  • @tugrulyldrm5699
    @tugrulyldrm5699 3 ปีที่แล้ว

    very cool

  • @karthikhanasi6052
    @karthikhanasi6052 6 ปีที่แล้ว

    hi, I am not able to get the lines as expected like if first line has 3 lines but the first line overlapping to the next lines.
    If the last line has 3 or 4 lines that time the line is expanding any solution or i am missing anything.

    • @karthikhanasi6052
      @karthikhanasi6052 6 ปีที่แล้ว

      Hey, I am accessing data from the database and using a while loop for that and using your code and you have foreach loop with manual input array any solution for that.

  • @antonioarjonesbello807
    @antonioarjonesbello807 5 ปีที่แล้ว

    Hi bro, thx so much, u solved my life!

  • @Brancoec
    @Brancoec 7 ปีที่แล้ว

    Hi, can you please help me?
    Tried your code source using mysql but I'm only getting the first row of it can you help me out on that?

    • @Brancoec
      @Brancoec 7 ปีที่แล้ว

      here's my email branco.ec@gmail.com, if you need I can send you the code I tried to modify, this is what I'm looking for, realy appreciate your tuto, thanks.

    • @Brancoec
      @Brancoec 7 ปีที่แล้ว

      Done great, it was not well done my query, You just saved my day, thanks a lot, you'r the man.

    • @Brancoec
      @Brancoec 7 ปีที่แล้ว

      Do you know a way to vertically align text in cells to the top, in case a this example of yours my left and right cells are item number and item quantity, so when text are wrapped both cells stays vertically centered ?
      Thanks in advance.

    • @Brancoec
      @Brancoec 7 ปีที่แล้ว

      Many thanks, I will give it a try, thanks for looking for it

  • @tomassarmiento4857
    @tomassarmiento4857 6 ปีที่แล้ว

    hey bro, how do I modify the structure of the table?

  • @danisupriyadi_lampung
    @danisupriyadi_lampung 4 ปีที่แล้ว

    Tutorial bagus, terimakasih

  • @tobiasopiyo4522
    @tobiasopiyo4522 6 ปีที่แล้ว

    hello,i'm a bit late but kindly bare with me. am trying to run your code but experiencing an error exception titled array to string conversion on the fpdf file, how do i solve that?

    • @tobiasopiyo4522
      @tobiasopiyo4522 6 ปีที่แล้ว

      the php tells me that the error is on the pdf file,which i doubt,let me try convert the array am supposed to print on the pdf to a string and see if it works

    • @tobiasopiyo4522
      @tobiasopiyo4522 6 ปีที่แล้ว

      no success,can i send you part of the code so you can highlight where i've gone wrong

    • @tobiasopiyo4522
      @tobiasopiyo4522 6 ปีที่แล้ว

      or rather send me the source code to opiyotobias9@gmail.com

    • @tobiasopiyo4522
      @tobiasopiyo4522 6 ปีที่แล้ว

      thank you,your channel isnt accessible,do you have tuitorial on creating a pdf where the tables overlap in more than one page

    • @tobiasopiyo4522
      @tobiasopiyo4522 6 ปีที่แล้ว

      it has helped but i'm getting this php error while using class PDF extends FPDF, the error says class declarations may not be nested, how can i solve that?

  • @pimudithawickramasekara2187
    @pimudithawickramasekara2187 3 ปีที่แล้ว

    excelent

  • @kevinhernandezarango5005
    @kevinhernandezarango5005 6 ปีที่แล้ว

    does this work in Tcpdf?

  • @suharyadi2957
    @suharyadi2957 6 ปีที่แล้ว

    mantap tutorial nya gan

  • @rushrun21
    @rushrun21 6 ปีที่แล้ว

    Thanks Gemul Channel !

  • @kowsalyag481
    @kowsalyag481 4 ปีที่แล้ว

    Hello.please upload how to display image in PDF from database

  • @raginishrivastava3615
    @raginishrivastava3615 7 ปีที่แล้ว

    very nice but background music should be slow...... not able to listen voice properly

  • @sadenlav
    @sadenlav 6 ปีที่แล้ว

    How to add unicode font for support another language

    • @sadenlav
      @sadenlav 6 ปีที่แล้ว

      Cambodia

    • @sadenlav
      @sadenlav 6 ปีที่แล้ว

      no problem

  • @dannarchiejabilles973
    @dannarchiejabilles973 6 ปีที่แล้ว

    If 1 cell is more than 1 page. how it looks like? thank you.

    • @dannarchiejabilles973
      @dannarchiejabilles973 6 ปีที่แล้ว

      can you try doing it please? make 1 cell data longer than 1 page. not the cell is more than 1 page but the data inside the cell is more than 1 page. thank you.

  • @juancarlosgomezperez5288
    @juancarlosgomezperez5288 6 ปีที่แล้ว

    muchas gracias me srivio de mucho

  • @vijaytallolli
    @vijaytallolli 4 ปีที่แล้ว

    How to the same with Multiple Multicell Height

  • @Hades2023
    @Hades2023 7 ปีที่แล้ว

    Thank you! Gemul.

  • @lazymacs2823
    @lazymacs2823 3 ปีที่แล้ว

    nc tutorial

    • @GemaCode
      @GemaCode  3 ปีที่แล้ว

      Thank you! :)

  • @carl2np
    @carl2np 6 ปีที่แล้ว

    hello thank you for this tutorial can i get the source code please

    • @carl2np
      @carl2np 6 ปีที่แล้ว

      carl2np@gmail.com

    • @carl2np
      @carl2np 6 ปีที่แล้ว

      thanks a lot i just get it

    • @carl2np
      @carl2np 6 ปีที่แล้ว

      please how can i do the same with database please

  • @ellhnkouvelis6421
    @ellhnkouvelis6421 7 ปีที่แล้ว

    hi excellent but in python don't have

  • @erzascarlet2145
    @erzascarlet2145 4 ปีที่แล้ว

    can you please post up the code.

  • @parmanandkushwah5494
    @parmanandkushwah5494 6 ปีที่แล้ว

    hello please send me a source code of this PDF report

    • @parmanandkushwah5494
      @parmanandkushwah5494 6 ปีที่แล้ว

      thanks this video is my very-very help full and thanks-a-lot........

  • @lizbethpina4254
    @lizbethpina4254 7 ปีที่แล้ว

    hello you can send me your source code?.... please

  • @chathurikaedirisinghe2337
    @chathurikaedirisinghe2337 6 ปีที่แล้ว

    can you send me the source code

  • @kaushalverma4386
    @kaushalverma4386 4 ปีที่แล้ว

    its too much difficult

  • @IrwanKurniawan45
    @IrwanKurniawan45 5 ปีที่แล้ว

    Tutorial yang sangat bermanfaat, kalau boleh saya juga mau minta source code nya. kirim ke email saya boyimam67@gmail.com . terima kasih

  • @denylowprime3118
    @denylowprime3118 7 ปีที่แล้ว

    Sangat bermanfaat. Gan, bisa kirim source codenya ke email saya denylowprime@gmail.com. Thx

    • @ridhozahtra2194
      @ridhozahtra2194 6 ปีที่แล้ว

      selamat siang, kebetulan saya juga mengalami masalah dengan wraptext saat membuat laporan pdf. kalau boleh saya juga mau minta source code nya. kirim ke email saya ridhozahtra@gmail.com . terima kasih

  • @BryanPratisia
    @BryanPratisia 6 ปีที่แล้ว

    Tutorial yang sangat membantu sekali, saya mendapat sedikit masalah dalam penyesuaian border dalam tabel agar dapat mengikuti isi yang ada pada tabel. tapi saya masih sedikit bingung dengan tutorial melalui video. boleh saya meminta source code nya? email saya bryan.pratisia16@gmail.com. terima kasih atas bantuannya

  • @kaushalverma4386
    @kaushalverma4386 4 ปีที่แล้ว

    it

  • @ridhozahtra2194
    @ridhozahtra2194 6 ปีที่แล้ว

    selamat siang, kebetulan saya juga mengalami masalah dengan wraptext saat membuat laporan pdf. kalau boleh saya juga mau minta source code nya. kirim ke email saya ridhozahtra@gmail.com . terima kasih

  • @ekavenifenariyati5237
    @ekavenifenariyati5237 6 ปีที่แล้ว

    Gan, boleh saya minta source code nya ngak? email saya ekavenifena@gmail.com .terima kasih atas bantuannya..

  • @yusupsupriatna922
    @yusupsupriatna922 5 ปีที่แล้ว

    Boleh minta source code nya ka ? emailnya yusupsupriatna712@gmail.com
    terima kasih ka

    • @yusupsupriatna922
      @yusupsupriatna922 5 ปีที่แล้ว

      @@GemaCode sip terimakasih ka ,
      ka apakah ada yang buat untuk ke excelnya juga ???

    • @yusupsupriatna922
      @yusupsupriatna922 5 ปีที่แล้ว

      belum ka, bentar saya coba cari