Create a Multilanguage PDF in Python
Hi guys, I'm disprate with the Pdf Unicode. I try to create a class using ufpdf but some chars are not correct and now I would like try Python because a friend tolds me that it's very powerful. I need a simple script in Python that grab all Records from a MySql table and print in the pdf file. The languages stored in my db are about 25 and they are: Greek English French Hungarian Italian Lithuanian Dutch Portuguese Albanian Czech Danish German Spanish Estonian Finnish Irish Latvian Maltese Polish Romanian Russian Slovene Slovak Swedish Anyone can help me, please? Thanks Perseo -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
Hi again, WORKS!!! I download all I need as python + reportlab. Only 2 questions: 1. I need all of this package? because it is 6Mb! 2. How can I connect my software with MySql. In my Hosting is present the Python support but I don't thing that the MySQLdb is present. How can I solve this little problem? Thanks Perseo Rob Wolfe wrote: > "Perseo" <[EMAIL PROTECTED]> writes: > > > Hi guys, > > > > I'm disprate with the Pdf Unicode. I try to create a class using ufpdf > > but some chars are not correct and now I would like try Python because > > a friend tolds me that it's very powerful. > > I need a simple script in Python that grab all Records from a MySql > > table and print in the pdf file. > > > > The languages stored in my db are about 25 and they are: > > Greek English French Hungarian Italian Lithuanian Dutch Portuguese > > Albanian > > Czech Danish German Spanish Estonian Finnish Irish Latvian Maltese > > Polish Romanian > > Russian Slovene Slovak Swedish > > You can give reportlab [1] a try. It has support for TrueType fonts > and unicode translation using UTF-8. I used to use it for pdf files > with polish chars. > > Some example code: > > > from reportlab.pdfbase import pdfmetrics > from reportlab.pdfbase.ttfonts import TTFont > from reportlab.pdfgen import canvas > > pdfmetrics.registerFont(TTFont('Verdana', 'Verdana.ttf')) > c = canvas.Canvas("pl.pdf") > c.setFont("Verdana", 12) > c.drawString(100, 600, "Witaj, ¶wiecie!".decode("iso-8859-2").encode("utf-8")) > c.showPage() > c.save() > > > > [1] http://www.reportlab.org/ > > -- > HTH, > Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
Hi Rob, thank you for your answer, but I'm a newbie in Web application written in Python. Now I try your suggestion ... Thanks Perseo Rob Wolfe wrote: > "Perseo" <[EMAIL PROTECTED]> writes: > > > Hi guys, > > > > I'm disprate with the Pdf Unicode. I try to create a class using ufpdf > > but some chars are not correct and now I would like try Python because > > a friend tolds me that it's very powerful. > > I need a simple script in Python that grab all Records from a MySql > > table and print in the pdf file. > > > > The languages stored in my db are about 25 and they are: > > Greek English French Hungarian Italian Lithuanian Dutch Portuguese > > Albanian > > Czech Danish German Spanish Estonian Finnish Irish Latvian Maltese > > Polish Romanian > > Russian Slovene Slovak Swedish > > You can give reportlab [1] a try. It has support for TrueType fonts > and unicode translation using UTF-8. I used to use it for pdf files > with polish chars. > > Some example code: > > > from reportlab.pdfbase import pdfmetrics > from reportlab.pdfbase.ttfonts import TTFont > from reportlab.pdfgen import canvas > > pdfmetrics.registerFont(TTFont('Verdana', 'Verdana.ttf')) > c = canvas.Canvas("pl.pdf") > c.setFont("Verdana", 12) > c.drawString(100, 600, "Witaj, ¶wiecie!".decode("iso-8859-2").encode("utf-8")) > c.showPage() > c.save() > > > > [1] http://www.reportlab.org/ > > -- > HTH, > Rob -- http://mail.python.org/mailman/listinfo/python-list
Python Expert
Hi guys, we are looking for a python developer for a European project. This project is multilangual and free it is called EuroCv and it need a module for exporting data in PDF. As web developer I try to create this module but It's too complicate for me. Check out the service www.eurocv.eu for more details. Contact us by Skype chat system our nick is eurocv. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Re:
Hi Keith Perkins Yes of course but we are looking for a developer who help us too. Keith Perkins wrote: > wrote: > > Hi guys, > > > > we are looking for a python developer for a European project. This > > project is multilangual and free it is called EuroCv and it need a > > module for exporting data in PDF. As web developer I try to create this > > module but It's too complicate for me. Check out the service > > www.eurocv.eu for more details. Contact us by Skype chat system our > > nick is eurocv. > > > > Thanks > > > have you looked at the reportlab module? http://www.reportlab.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
I can't upload in the PYTHONPATH but in a normal folder of our site. Exist another way to do it? Thanks Rob Wolfe wrote: > Perseo wrote: > > Hi again, > > > > WORKS!!! I download all I need as python + reportlab. Only 2 questions: > > > > 1. I need all of this package? because it is 6Mb! > > I'm afraid you need all of it. > BTW My reportlab package is only 3MB... hmm strange. > > > 2. How can I connect my software with MySql. In my Hosting is present > > the Python support but I don't thing that the MySQLdb is present. How > > can I solve this little problem? > > You can install MySQLdb wherever you want. You need only to make > sure the module is in your PYTHONPATH. > > HTH, > Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
Thanks I will try it. Diez B. Roggisch wrote: > Perseo wrote: > > > I can't upload in the PYTHONPATH but in a normal folder of our site. > > Exist another way to do it? > > PYTHONPATH is an environment variable. You can set it to arbitrary paths, > and python will look for module there, too. Or you modify sys.path before > you try the import. > > Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
Nothing to do! I enable test2.py and the folder with 777 permission and I write at the top of the file the PYTHONPATH "#!/usr/bin/python" as you told me but it doesn't works as well. this is my organization: www.domain.com/python/reportlab/ [all files] www.domain.com/python/test2.py #!/usr/bin/python print "Content-Type: text/html\n\n" print "Hello World" from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfgen import canvas pdfmetrics.registerFont(TTFont('Verdana', 'Verdana.ttf')) c = canvas.Canvas("pl.pdf") c.setFont("Verdana", 12) c.drawString(100, 600, "Witaj, ¶wiecie!".decode("iso-8859-2").encode("utf-8")) c.showPage() c.save() The verdana font doesn't exist in the reportlab fonts folder. I try to delete the rows where it is called like (registerFont, setFont) but nothing to do. any suggestion?! Diez B. Roggisch wrote: > Perseo wrote: > > > I can't upload in the PYTHONPATH but in a normal folder of our site. > > Exist another way to do it? > > PYTHONPATH is an environment variable. You can set it to arbitrary paths, > and python will look for module there, too. Or you modify sys.path before > you try the import. > > Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
PERFECT! Done! Thanks Now I create a little file in pdf format but the data are in the MySql database! :( How can I connect to it? Thanks for all suggestions Perseo Rob Wolfe wrote: > Perseo wrote: > > Nothing to do! > > I enable test2.py and the folder with 777 permission and I write at the > > top of the file the PYTHONPATH "#!/usr/bin/python" as you told me but > > it doesn't works as well. > > #!/usr/bin/python is not PYTHONPATH. I think you should > read this: > http://docs.python.org/tut/node4.html#SECTION00422 > > > The verdana font doesn't exist in the reportlab fonts folder. I try to > > delete the rows where it is called like (registerFont, setFont) but > > nothing to do. > > Fonts are not part of reportlab package. You should find it > in your OS or in the net. You need to know what font do you want to > use. > > > any suggestion?! > > Install reportlab package in your home directory, for example > /home/perseo/python/lib > > and then in the shell write this: > > export PYTHONPATH=/home/perseo/python/lib > > and look here: > http://docs.python.org/tut/node8.html#SECTION00811 > > HTH, > Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
It's too difficult for me, anyone can help me contact me thru chat or something else, please. It drives me crazy! Perseo wrote: > PERFECT! Done! Thanks > Now I create a little file in pdf format but the data are in the MySql > database! :( > How can I connect to it? > > Thanks for all suggestions > Perseo > > > Rob Wolfe wrote: > > Perseo wrote: > > > Nothing to do! > > > I enable test2.py and the folder with 777 permission and I write at the > > > top of the file the PYTHONPATH "#!/usr/bin/python" as you told me but > > > it doesn't works as well. > > > > #!/usr/bin/python is not PYTHONPATH. I think you should > > read this: > > http://docs.python.org/tut/node4.html#SECTION00422 > > > > > The verdana font doesn't exist in the reportlab fonts folder. I try to > > > delete the rows where it is called like (registerFont, setFont) but > > > nothing to do. > > > > Fonts are not part of reportlab package. You should find it > > in your OS or in the net. You need to know what font do you want to > > use. > > > > > any suggestion?! > > > > Install reportlab package in your home directory, for example > > /home/perseo/python/lib > > > > and then in the shell write this: > > > > export PYTHONPATH=/home/perseo/python/lib > > > > and look here: > > http://docs.python.org/tut/node8.html#SECTION00811 > > > > HTH, > > Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Create a Multilanguage PDF in Python
Hi Rob this is my code: #!/usr/bin/python import time, os, sys from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfgen import canvas from reportlab.lib.units import inch, cm from reportlab.lib.pagesizes import A4 #precalculate some basics top_margin = A4[1] - inch bottom_margin = inch left_margin = inch right_margin = A4[0] - inch frame_width = right_margin - left_margin pdfmetrics.registerFont(TTFont('Verdana', 'verdana.ttf')) canv = canvas.Canvas("test.pdf") def drawPageFrame(mycanv): mycanv.line(left_margin, top_margin, right_margin, top_margin) mycanv.setFont('Verdana',12) mycanv.drawString(left_margin, top_margin + 2, "Pdf Test") mycanv.line(left_margin, top_margin, right_margin, top_margin) mycanv.line(left_margin, bottom_margin, right_margin, bottom_margin) mycanv.drawCentredString(0.5*A4[0], 0.5 * inch, "Page %d" % mycanv.getPageNumber()) canv.setPageCompression(1) drawPageFrame(canv) #do some title page stuff canv.setFont("Verdana", 36) canv.drawCentredString(0.5 * A4[0], 7 * inch, "Pdf Test") canv.setFont("Verdana", 18) canv.drawCentredString(0.5 * A4[0], 5 * inch, "Test Staff") canv.setFont("Verdana", 12) tx = canv.beginText(left_margin, 3 * inch) tx.textLine("This is a test to a PDF Exporting Tool") canv.drawText(tx) canv.showPage() canv.save() print "Content-Type: text/html\n\n" print "PDF Test" I would like to create a simple pdf splitted in two column with a vertical row. | Όνομα, Επώνυμο | John, Malkovic Διεύθυνση (1) | 11 Main Street, Athens 54640 | Thessaloniki Greece Διεύθυνση (2) | Τηλέφωνο | 00302310886995 Διεύθυνση | [EMAIL PROTECTED] ηλεκτρονικού | ταχυδρομείου | Κινητό τηλέφωνο | 00345353453453 Τόπος γέννησης | Thessaloniki Χώρα | Greece Υπηκοότητα | Greek Ημερομηνία | γέννησης | Μητρική γλώσσα | Greek Rob Wolfe wrote: > "Perseo" <[EMAIL PROTECTED]> writes: > > > Hi guys, > > > > I'm disprate with the Pdf Unicode. I try to create a class using ufpdf > > but some chars are not correct and now I would like try Python because > > a friend tolds me that it's very powerful. > > I need a simple script in Python that grab all Records from a MySql > > table and print in the pdf file. > > > > The languages stored in my db are about 25 and they are: > > Greek English French Hungarian Italian Lithuanian Dutch Portuguese > > Albanian > > Czech Danish German Spanish Estonian Finnish Irish Latvian Maltese > > Polish Romanian > > Russian Slovene Slovak Swedish > > You can give reportlab [1] a try. It has support for TrueType fonts > and unicode translation using UTF-8. I used to use it for pdf files > with polish chars. > > Some example code: > > > from reportlab.pdfbase import pdfmetrics > from reportlab.pdfbase.ttfonts import TTFont > from reportlab.pdfgen import canvas > > pdfmetrics.registerFont(TTFont('Verdana', 'Verdana.ttf')) > c = canvas.Canvas("pl.pdf") > c.setFont("Verdana", 12) > c.drawString(100, 600, "Witaj, ¶wiecie!".decode("iso-8859-2").encode("utf-8")) > c.showPage() > c.save() > > > > [1] http://www.reportlab.org/ > > -- > HTH, > Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Expert
Hi again, I must create a webpage with this service not a standalone software. Is it correct, anyway? have you a little example to show me? Thanks for your suggestions. Frithiof Andreas Jensen wrote: > "Perseo" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi guys, > > > > we are looking for a python developer for a European project. This > > project is multilangual and free it is called EuroCv and it need a > > module for exporting data in PDF. > > A brute-force approach could be to sidestep PDF and design a > template(s) in LaTex containing fields identified by strings. LaTeX > can produce many formats, one of those is PDF. > > Then have your output module read the template, do a search & replace > of the fields with values (remembering to quote the characters that > LaTex will choke on and removing the codes for the blank fields) and > write the finished LaTeX document to disk. (Maybe there are even > templating modules in Python that will take care of this). > > Then compile the documents with latex, run the resulting *.dvi file > through dvipdf and return a link to it. This is a "compiler pattern". > You need a naming scheme to identify your file(s) but the rest is > pretty old. > > The Python application "scons" (a make replacement) can control the > "build" process - in case that you are not on a unix box - one could > have "build" application periodically looking for *.tex files and > compile them into *pdf whenever one is deposited in the right place. > Scons support distributed builds b.t.w. > > > > As web developer I try to create this > > module but It's too complicate for me. Check out the service > > www.eurocv.eu for more details. Contact us by Skype chat system our > > nick is eurocv. > > > > Thanks > > -- http://mail.python.org/mailman/listinfo/python-list