I need a fix on a bit of HTML/CSS code. First person who posts the solution (in form of complete HTML code that works) here will get the $25 reward Here is how: Please go to http://208.115.224.243/test.php and click on "Generate PDF" at the bottom, you will see how in the generated PDF file the lines wrap. I need those individual lines to NOT wrap, something similar to doing <nobr>this line should not break</nobr> The problem is, my pdf generator does not seem to understand the <nobr> tag neither it seems to understand the css white-space property, so i am in need of another solution. Please experiment with the code and try out every tricks that you know, once you achieve a working result - post your HTML code here in this thread First person to reply here with a working solution will get $25 to their paypal Good luck, and thanks
This isn't the contest section, Post at - http://forums.digitalpoint.com/forumdisplay.php?f=94 for contests as I doubt any developers will want to spend their time for 'perhaps you will get to be the first' type of job in this sub forum
Works: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <style media="all"> .unchecked { white-space: nowrap; } .nowrap{ white-space: nowrap; } </style> <body> <table width="600" border="1" cellspacing="0" cellpadding="0"> <tr> <td class="nowrap"> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> </td> </tr> </table> </body> </html> Code (markup): PM for my paypal.
http://www.mywot.com/en/scorecard/208.115.224.243 Just a quick heads up and it looks to me the above should work fine. I think your problem lies elsewhere. N.
No lines break, tried all possible browers.... But what do you actually want? To remove the border around the text?
why would i ever care about reputation of my testing server on some "i don't care about" reputation site called mywot ? lol it's a vps recently leased by me .. if you have trouble with those IPs, contact the hosting company that owns the servers (named ideastak) ok ppl .. please .. if you are not about to fix my code, please stop hijacking this post with your irrelevant thoughts and guesses about web server reputations, estimated number of contest-lovers, number of stars on the sky or the height of an elf ..
When you click the "generate PDF" button on bottom of page, it will generate a PDF file from the HTML code you enter into the box. If you then open the pdf file, you will see that lines wrap.. each line that says "[] this line should not break", should actually NOT wrap at all .. it should completely be on a single line. The whole text may wrap before or after that snippet, but NOT in the middle of it.. so .. for instance .. this is a CORRECT way for it to be [] this line should not break [] this line should not break [] this line should not break [] this line should not break [] this line should not break [] this line should not break [] this line should not break [] this line should not break and this is a WRONG way [] this line should not break [] this line should not break [] this line should not break [] this line should not break [] this line should not break it is wrong because some lines wrap in the middle of the text snippet "[] this line should not break" (which in my code is put in <span>s) Hope this explains
There's something wrong with your PDF generating backend. Try the following code I gave, paste it in notepad, save it as something.html and open it in firefox. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <style media="all"> .unchecked { white-space: nowrap; display:block; } </style> <body> <table width="600" border="1" cellspacing="0" cellpadding="0"> <tr> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> </td> </tr> </table> </body> </html> Code (markup):
well ive always had this problem when it comes to converting html to pdf, most of the time, the styles are ignored/discarded by the converter, in this case, a table would probably do the job instead of a span
Yes the pdf generator is not a browser, and it does not render just like a browser would do .. and i told about that in my first post. My own HTML shows just fine in a browser too .. I need to try out all possible alternative ways and see which way would work with my pdf generator oh and i forgot to tell .. the pdf generator is the tcpdf
I have generated loads and loads of pdf documents with php and this problem is not entirely a html issue. It is a combination of the html and php. Unless you show us the php code, we can not fix your problem.
The php code is not of much interest unless you are willing to edit the whole tcpdf system. If you are interested in the PHP source, it's an open-source pdf generator (so far the best i found) called tcpdf (http://www.tcpdf.org/) and widely used in popular systems such as joomla. If you have the guts to edit the tcpdf to make it understand the CSS white-space property, be my guest .. i'll pay you double of what promised if you can make tcpdf to recognize that
The problem is, in my real code the text is dynamically generated by php (based on user input) and i don't know the length of each snippet. If i create a table, that will mean assigning equal space for each snippet and that space will be equal to the longest of the snippets, meaning the very short ones would still occupy a line while there can be 3-4 of those short things on one line in real life. to better understand, imagine a form that you fill up and check some checkmarks imagine the form is.. ( the []'s are checkboxes) ------------- what colors do you like ? [] red [] green [] white [] blue [] black [] purple [] light yellow [] orange [] very dark red ------------- so now, when you choose some of those colors, the script will generate a PDF based on your output, and i of course want the PDF to be as compact as possible. That is why i would NOT put every answer on a single line, instead i would want it to appear something like this ------------- [] red [] blue [] black [] very dark red [] green [] light yellow ------------- but NOT something like this ------------- [] red [] blue [] black [] very dark red [] green [] light yellow ------------- and i can not predict a place for each answer because i don't know how many colors will you choose .. you may choose only 2, you may choose all of them .. i simply don't know hope this makes it clearer
Hello, refer to this thread http://forums.digitalpoint.com/showthread.php?t=2380579 Maybe this code will solve your problem. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <style media="all"> .unchecked { white-space: nowrap; } </style> <body> <table width="600" border="1" cellspacing="0" cellpadding="0"> <table> <tr> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" /> Red</span> </td> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" /> Blue</span> </td> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" /> Dark</span> </td> </tr> <tr> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" /> Very Dark</span> </td> </tr> <tr> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" /> Green</span> </td> <td> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" /> Light Yellow</span> </td> </tr> </table> </table> </body> </html> PHP:
Just one question, is using tables, spans and only existing styles a must, or we can reformulate the entire code?
For the reasons explained above in this thread, there can not be table cells .. if it was about table cells, i would have done it without posting anything here .. It should be continued text, and not a text split by fixed positions of table cells.. tables simply not a solution to this
If you don't want a table, you can use div <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <style type="text/css" media="all"> span.unchecked { white-space: nowrap; } </style> <body> <table style="width: 100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td><div style="width:100%;padding: 0;margin: 0;"> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span><span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> </div> <div style="width:100%;padding: 0;margin: 0;"><span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> </div> <div style="width:100%;padding: 0;margin: 0;"> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> <span class="unchecked"><img src="http://208.115.224.243/checked-inline.gif" width="8" height="8" />this line should not break</span> </div> </td> </tr> </table> </body> </html> PHP: