I'm using xhtml2pdf
(former pisa
, or is it vice versa? :)) to generate PDF from the django template. The template is rendered ok, but PDF I get from that template is corrupted in a very weird manner: text in table cells are lifted to the top of the cell, so capital letters touch the upper border of the cell:
While in the browser it looks like that:
I've tried:
- Applying
vertical-align
- looks like it's just ignored, at least I didn't notice any changes in pdf, even if they were in generated html - Applying
padding-top
- it moves the text down, but increases the cell height as well. - Wrapping text into
span
withmargin-top
- same effect aspadding-top
I think the reason is that text is rendered by xhtml2pdf at the very top of the line, while browsers tend to render it somewhere in the middle of the block. In other words the text block occupies the very same position both in pdf and html, but the text inside the block is shifted. But that's just my speculation.
So, has anyone faced the same issue? Am I doing something wrong? Any workarounds possible?
Pieces of code:
- Rendered html: http://pastebin.com/4jMCLrA4
- CSS: http://pastebin.com/vAn8HXkY
- Code that generates PDF: http://pastebin.com/6wBULrhx