From: Rafael C. <raf...@gm...> - 2015-02-12 22:02:26
|
Hi Vitaly, Thank you very much for you contribution. I will add your lines to the function before send the update. Also, I will add: * "Greater/Less than or equal to" comparisons instead of "Greater/Less than" to cover the possibility of exact matches (even character width are calculated at the level of 1/1000 dpi). * The use of soft-hyphen instead of hard-hyphen as break points. * Other contributions. The problem that you points out, also occurs when null, line-feed, carriage-return, back-slash, single-quote, double-quotes, and control-Z are escaped. This occurs when we use functions like mysqli_real_escape_string() --e.g. inside of function DB_escape_string()--. It is pending: * The use of curly braces {} to access characters in a string. Some PHP's documents say that this syntax is deprecated, but other do not (ref: php.net/manual/de/language.types.string.php vs. php.net/manual/en/language.types.string.php). Also, we have concerns about how multi-byte safe is. Best regards, Rafael. 2015-02-12 13:45 GMT-06:00 Vitaly Shevkunov <vsh...@so...>: > Rafael, > > Your function looks much more readable than the original. I also like that > it does splitting on the "\n" instead of relying on some external code to > do that. > I will try it on my test system to see how much it will affect various > forms. > > So far I noticed that sometimes a text, pasted from the text editor, may > have \r\n encoded as a text. It looks like that in PDF > line1\r\nline2\r\n > instead of > line1 > line2 > > I would like to add this to you function to cover all possible line ending > combinations > > $text = str_replace('\r','',$text); // single quotes - no string parsing > in PHP > $text = str_replace('\n',"\n",$text); // replace '\n' text with new line > character > > Regards, > > Vitaly > > > On 2/11/2015 4:44 PM, Rafael Chacón wrote: > > Hi Andrew, > > I enclose my new AddTextWrap. Inside ~/includes/class.pdf.php, replace > AddTextWrap lines (80-169) with lines 3-66 of the included file. > > Comments: > * I'm testing with last version of Nicola Asuni's TCPDF. > * It is possible to replace line 56 ("$textwidth += > $this->GetStringWidth($c);") with two lines. Those two lines makes the > function a little faster in some cases ($text width near the cell width), > but slower in other cases ($text width far from the cell width). > > Best regards, Rafael. > > 2015-02-11 16:19 GMT-06:00 Andrew Galuski <aga...@re...>: > >> I am trouble shooting the same problem today where it wraps text >> smaller than the width. The added $s = trim($s).' ';" causes an issue >> for me. Or you can change a do while loop from < to <= $nb and it appears >> to fix same issue. My worry was testing all existing forms. If you can send >> me your update I will test it in my environment for all my forms. >> >> Sent from my BlackBerry 10 smartphone on the Verizon Wireless 4G LTE >> network. >> *From: *Rafael Chacón >> *Sent: *Wednesday, February 11, 2015 3:26 PM >> *To: *webERP Developers >> *Reply To: *webERP Developers >> *Subject: *Re: [WebERP-developers] PDF generator in webERP. >> >> Hi Vitaly, >> >> Thank you for writing. >> >> About >> "$lines=explode("\r\n",htmlspecialchars_decode($myrow2['narrative']));": >> This line returns an array of strings, each of which is a substring of >> $myrow2['narrative'] formed by splitting it on boundaries formed by the >> characters Carriage_Return ("\r") and Line_Feed ("\n"). It only works for >> msWindows (Unix-like and Mac OS-10 use Line_Feed; Mac OS up to version 9 >> uses Carriage_Return). >> >> The problem in PrintCustTransPortrait.php (and other reports) is caused >> by two bugs in AddTextWarp(): >> >> 1. Line 108: "$s = trim($s).' ';" (extra blank character -> the extra >> white line). >> 2. Lines from 106 to 164: (the logic of the code -> splitting in the last >> white_space of a segment smaller that the cell width). >> >> My purpose in asking if someone "has problem with this function (last >> line line-feeded before the end) ?" is know who else experiences that >> problem. >> >> I have a new AddTextWrap that fixes both bugs. It is faster and produces >> PDF files with a slightly smaller size, but --obviously-- it not produce >> the extra blank line in segments smaller than cell width. Many users like >> this (no extra blank line) but there are some users who ask me to re-do >> this extra blank line. >> >> I would like other people tests this new AddTextWrap. Although this extra >> blank line is a bug, I am not comfortable with the idea of a potential >> change in actual reports. >> >> Best regards, Rafael. >> >> >> 2015-02-11 8:25 GMT-06:00 Vitaly Shevkunov <vsh...@so...>: >> >>> Rafael, >>> >>> The addTextWrap() does not split the line like that. It is done by this >>> function >>> $lines=explode("\r\n",htmlspecialchars_decode($myrow2['narrative'])); >>> >>> in PrintCustTransPortrait.php >>> >>> >>> Vitaly >>> >>> >>> On 2/10/2015 9:38 PM, Rafael Chacón wrote: >>> >>> HI Phil, >>> >>> Thank you for your answer. >>> >>> Topic 1: From R&OS -> FPDF -> TCPDF. For future pdf development, I think >>> it will be better to directly use TCPDF: (a) Y-coordinate= instead of >>> calculating as from page-bottom to cell-bottom and the script class.pdf.php >>> translates to page-top to cell-top to use tcpdf.php, we can directly use >>> page-top to cell-top and TCPDF; (b) TCPDF has interesting functions >>> (writeHTML, writeHTMLCell, etc.) to write code html (a screen report) into >>> a pdf. >>> >>> Topic 2: tcpdf 6.2.6 has new fonts and others.They may be helpful to >>> give more options to reports. >>> >>> Topic 3: With PrintCustTransPortrait.php (and other reports) I have >>> unexpected breaks (see enclose) and prints lines with whitespace. The >>> problems are inside AddTextWarp(). >>> >>> Regards, Rafael. >>> >>> >>> 2015-02-09 22:34 GMT-06:00 Phil Daintree <ph...@lo...>: >>> >>>> Yes originally used R & OS pdf library. >>>> Moved to Oliver Plathey FPDF http://www.fpdf.org/ >>>> The class.pdf.php was created to allow the transition to FPDF >>>> ... then to TCPDF which was a development of FPDF which allowed utf-8 >>>> pdfs - using CID fonts rather than embedding a large monster font file into >>>> each pdf - so a small 10k report becomes 2 Meg. This was not considered >>>> acceptable. >>>> I update tcpdf from time to time. >>>> >>>> Not sure about 3. >>>> >>>> Phil >>>> >>>> Phil Daintree >>>> Logic Works Ltd - +64 (0)275 567890 http://www.logicworks.co.nz >>>> >>>> On 10/02/15 13:37, Rafael Chacón wrote: >>>> >>>> Hi, >>>> >>>> Some questions: >>>> >>>> 1. webERP begun using PHP Pdf creation - R&OS ( >>>> http://sourceforge.net/projects/pdf-php/). Then, webERP moved to TCPDF >>>> (http://www.tcpdf.org/). Javier de Lorenzo-Cáceres wrote >>>> ~/includes/class.pdf.php to use TCPDF with "PHP_Pdf_creation_-_R&OS syntax" >>>> (old code). Is it right? >>>> >>>> 2. Someone has updated the ~/includes/tcpdf folder with TCPDF version >>>> 6.2.6 ? >>>> >>>> 3. Someone has replaced the function AddTextWarp() or has problem with >>>> this function (last line line-feeded before the end) ? >>>> >>>> Best regards, Rafael. >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Dive into the World of Parallel Programming. The Go Parallel Website, >>>> sponsored by Intel and developed in partnership with Slashdot Media, is your >>>> hub for all things parallel software development, from weekly thought >>>> leadership blogs to news, videos, case studies, tutorials and more. Take a >>>> look and join the conversation now. http://goparallel.sourceforge.net/ >>>> >>>> >>>> >>>> _______________________________________________ >>>> Web-erp-developers mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/web-erp-developers >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Dive into the World of Parallel Programming. The Go Parallel Website, >>>> sponsored by Intel and developed in partnership with Slashdot Media, is >>>> your >>>> hub for all things parallel software development, from weekly thought >>>> leadership blogs to news, videos, case studies, tutorials and more. >>>> Take a >>>> look and join the conversation now. http://goparallel.sourceforge.net/ >>>> _______________________________________________ >>>> Web-erp-developers mailing list >>>> Web...@li... >>>> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >>>> >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Dive into the World of Parallel Programming. The Go Parallel Website, >>> sponsored by Intel and developed in partnership with Slashdot Media, is your >>> hub for all things parallel software development, from weekly thought >>> leadership blogs to news, videos, case studies, tutorials and more. Take a >>> look and join the conversation now. http://goparallel.sourceforge.net/ >>> >>> >>> >>> _______________________________________________ >>> Web-erp-developers mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/web-erp-developers >>> >>> >>> >>> No virus found in this message. >>> Checked by AVG - www.avg.com >>> Version: 2015.0.5646 / Virus Database: 4284/9096 - Release Date: 02/11/15 >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Dive into the World of Parallel Programming. The Go Parallel Website, >>> sponsored by Intel and developed in partnership with Slashdot Media, is >>> your >>> hub for all things parallel software development, from weekly thought >>> leadership blogs to news, videos, case studies, tutorials and more. Take >>> a >>> look and join the conversation now. http://goparallel.sourceforge.net/ >>> _______________________________________________ >>> Web-erp-developers mailing list >>> Web...@li... >>> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >>> >>> >> >> >> >> >> ------------------------------------------------------------------------------ >> Dive into the World of Parallel Programming. The Go Parallel Website, >> sponsored by Intel and developed in partnership with Slashdot Media, is >> your >> hub for all things parallel software development, from weekly thought >> leadership blogs to news, videos, case studies, tutorials and more. Take a >> look and join the conversation now. http://goparallel.sourceforge.net/ >> _______________________________________________ >> Web-erp-developers mailing list >> Web...@li... >> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >> >> > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming. The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net/ > > > > _______________________________________________ > Web-erp-developers mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > > > No virus found in this message. > Checked by AVG - www.avg.com > Version: 2015.0.5646 / Virus Database: 4284/9102 - Release Date: 02/12/15 > > > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming. The Go Parallel Website, > sponsored by Intel and developed in partnership with Slashdot Media, is > your > hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials and more. Take a > look and join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Web-erp-developers mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > |