i have a mysql database that i'd like to query. i would like to format the results a certain way, then turn it into a pdf. in the past, i used PHP and FPDF, while it worked, it was a pain and tedious. i don't think PHP can handle this sort of thing. i don't have much experience in python or ruby but this would be a great project to do in either language so i can get more familiar. it doesn't have to be web based. it can be desktop script that i could run with a cron or manually. hope someone can point me to some resources. thanks.
-
sure there are many libraries for mysql in python and many libraries for pdf (they all are kind of a pain) ... all you need to do is combine one from each set and write some code – Joran Beasley Apr 24 '15 at 17:11
-
@joran is there one you prefer over another? – w1n78 Apr 24 '15 at 17:13
-
most people use mysqldb(although its kinda tough to setup on windows) ... pypdf is the only pdf libray i have messed with ... – Joran Beasley Apr 24 '15 at 17:14
-
@JoranBeasley great i'll check that out. i'm on osx so it shouldn't be an issue. otherwise i'll run a vm with linux. thanks. – w1n78 Apr 24 '15 at 17:15
2 Answers
In Ruby you have a number of options for your PDF authoring, and your DB management is very easy if you use the ActiveRecord library (comes with Rails) or Sequel to read or write data.
Complete and heavy duty PDF authoring can be done using Prawn... it requires some studying, but it's an amazing library.
You can also create HTML web pages and convert them into PDF using the wicked_pdf gem, which is quite simple to use.
Or, you can combine it all, or write simple PDF's with simple tables and text using the combine_pdf, which is as easy as it gets and also allows you to use PDF templates (so you can have a well designed template and just add the text you need).
I love Ruby and I think it's very easy to learn. Plus, it has more applications than just web programming - there's even a project called RubyMotion which lets you program native applications for iOS and Android using Ruby!
I'm sure you'll love Ruby.

- 18,516
- 2
- 45
- 67
-
great! thanks for the links. i have some stuff to mess with this weekend. – w1n78 Apr 24 '15 at 21:04
-
thanks, i will check those out. i think i know about the challenge with mysql and python. at least i ran into one that relates to the driver. but eventually i was able to figure it out. not sure if it's similar with this library. i'll play with these 2 and update once i get results. – w1n78 Apr 24 '15 at 17:19
-
Glad to have helped. Remember to accept answers that worked for you. @w1n78 – Awn Apr 24 '15 at 17:21