0

I'm currently creating a part of a program: I'm supposed to take an entirely HTML page, and get it into a WORD file. There are title, paragraph, graphic... But, into my HTML page, I also have table (tr, th, td, table tags). I parse it into a Word table. But, my table are too large, so I have some word that are cutting into parts. I expected something like this:

|Myentireword|

but it go out like this (because there are too many cell in one line)

|Myent|
|irewo|
|rd   |

It's really really ugly, so, I didn't see other solution than transforme my table into image, but I can't find the way to do this. (use my html-parsor, creatable a table of string, display it into an image, save the image, then load it into my Word document. I can do the first and second thing, and load an image in my document, but I do not have a way for creating the image itself.

  • I cannot change the output, it IS required to be a Word. Our custommer want to be able to modified and save it, and many customers are not really expert. So, I'm not able to use some PIL technic. (also, it does'nt solve my problem)

  • I already have a working parsor, and have ouput for my html, so i can't use something like "create a table from html"

  • I'm not able to use css, nor pdf-creating as I said, so this way won't work too: "Quality tables in python" But the question is exactly mine in that case!

  • I cannot use Matplotlib to crate table myself, because I do not know how to print into it, and I need something (If possible) to "merge" cells. If it's not, I'll do without, I juste need something working, it's really necessary, please!

Community
  • 1
  • 1
Albynn
  • 1
  • 2
  • 1
    *htmlparsor: https://docs.python.org/2/library/htmlparser.html *Generating docx: https://python-docx.readthedocs.org/en/latest/api/document.html?highlight=add%20table#docx.document.Document.add_table *Graphic: http://matplotlib.org/ – Albynn Nov 09 '15 at 09:34
  • Are you using an html parser? – SirParselot Nov 09 '15 at 09:46
  • Using PIL this is possible: http://stackoverflow.com/questions/5414639/python-imaging-library-text-rendering – Torxed Nov 09 '15 at 09:47
  • Torx: Okay, but how am I suppose to create an entire TABLE with this? I just see a word... And where does the ttf file come from? At least, waht is it? SirParselot: yes, i said it, and give the link into my comment - impossible to give more than 2 link for new users – Albynn Nov 09 '15 at 11:04

0 Answers0