A: 

Hello, I hope that this helps you a little bit: (I don't have an exact answer for you.)

Sometimes it is the best to rewrite a project, because you just make the same mistake again and again. By rewriting you have to rethink it and maybie the errors are disappearing.

Btw. you could use dict() instead of dict([]). And you don't need a xmlify-function, you could just use this:

from cgi import escape
print(escape("<a>1 & 3</a>"))
# prints &lt;a&gt;1 &amp; 3&lt;/a&gt;

Maybie the error has something to do with the æ in your csv. (It might be a bug in one of the used modules)

Joschua
I don't think that answers the question at all. Rewriting the project isn't a good answer.
Peter Bengtsson
A: 

Found a workaround myself. Based on some code changes made in rst2pdf, I was able to get my code working reliably. The solution, although ugly, is to wrap all my Paragraphs in the section of the code that creates Paragraphs for the student comments inside KeepTogether. For example, I changed one relevant line to:

reportDocContent.append(KeepTogether(Paragraph(commentParagraph, style=commentParagraphStyle)))

and now it works (at least, I haven't been able to break it yet after trying lots of sample data).

Gordon Worley
What was it before? Before you added the KeepTogether.I'm stuck with the same problem but I don't know how to squeeze in this magical KeepTogether thing.
Peter Bengtsson
Just wrap whatever it is you have inside KeepTogether. For example, before my code was `reportDocContent.append(Paragraph(commentParagraph, style=commentParagraphStyle))`. This really is some kind of abuse of KeepTogether, since I'm only putting in one thing, but it works.
Gordon Worley