remcoboerma / pyfpdf

Automatically exported from code.google.com/p/pyfpdf
GNU Lesser General Public License v3.0
0 stars 0 forks source link

handle None value passed to write as empty string #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Sometimes you just want to print objects that have properties that may be null 
(in my case printing fields from a django model) so having pyfpdf check for 
that and handle them as empty string would be nicer that having to add lot of 
checks for each field.

What steps will reproduce the problem?
1.  pdf.write(3, None);

What is the expected output? What do you see instead?
None handled like empty string. 

What version of the product are you using? On what operating system?
1.7

Original issue reported on code.google.com by riccardo...@gmail.com on 5 Jan 2013 at 11:24

GoogleCodeExporter commented 9 years ago
Maybe it is best to inherit FPDF class and override write method?
Or add new method like "write_replace_null_with_empty_string" to current FPDF 
class?

Original comment by romiq...@gmail.com on 8 Jan 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Well, i could inherit FPDF for sure but at least since write takes only string 
wouldn't be better to check its type and raise before trying to call .replace() 
on it? Which is quite the opposite of what i'm asking but at least makes the 
situation clear.

Original comment by riccardo...@gmail.com on 9 Jan 2013 at 8:24

GoogleCodeExporter commented 9 years ago
Ok. better error input handling. I'll propose patch.

Original comment by romiq...@gmail.com on 9 Jan 2013 at 8:41