writing plain text to multi page pdf

John Hunter <jdh2358@...149...> writes:

One of my colleagues want to use PdfPages to create several mpl
figures in one pdf document. It would be nice to be able to write
some text in there directly.

So the user interface might look something like this:

pdf = PdfPages('filename.pdf')
fig=figure()
# ...
pdf.savefig(fig)
pdf.annotate(123,456,'my text here',fontsize=12,font='Helvetica')
pdf.close()

Should the coordinates be raw PDF points measured from the bottom left
corner, or passed through the figure transformation (or something else)?
What sort of font properties would you expect to be allowed?

One could use the matplotlib.text.Text
and add it to your figure, and maybe this is the way to go,

I think that's what the pdf backend would end up doing internally, at
least if anything like coordinate transformations or any interesting
font properties need to be supported. It sounds like a fairly easy
change.

While we're discussing multi-page pdf files, would it be useful to have
pyplot-level support for them? It shouldn't be too hard to have pyplot
track your currently open pdf file and make, say, savefig with no
arguments direct the output to that. I personally don't have a use for
that, but do you think it would be a useful part of pyplot?

···

--
Jouni K. Sepp�nen
http://www.iki.fi/jks

Should the coordinates be raw PDF points measured from the bottom left
corner, or passed through the figure transformation (or something else)?
What sort of font properties would you expect to be allowed?

One could use the matplotlib.text.Text
and add it to your figure, and maybe this is the way to go,

I think that's what the pdf backend would end up doing internally, at
least if anything like coordinate transformations or any interesting
font properties need to be supported. It sounds like a fairly easy
change.

This is a tough call. mpk is not so good at multiline text. Maybe
the solution is to make mpl good at multiline text, but I was
wondering if there was an easy way to "dump a paragraph" at the pdf
level, and have it newline separate the text and make it look
acceptable. I don't really know enough about the pdf spec to know if
this is sensible. Of course, as soon as you support a little, people
will want you to support more, fonts and sizes and math and
what-have-you. So maybe the better solution is to make mpl multiline
text better.

While we're discussing multi-page pdf files, would it be useful to have
pyplot-level support for them? It shouldn't be too hard to have pyplot
track your currently open pdf file and make, say, savefig with no
arguments direct the output to that. I personally don't have a use for
that, but do you think it would be a useful part of pyplot?

The current interface looks easy enough to use -- it just needs to be
advertised better, eg in a FAQ ( I had to read the source to find it,
which works well enough for me, but not for everyone). If you want to
write one up, I'll add it to the docs.

JDH

···

On Fri, Aug 28, 2009 at 4:27 AM, Jouni K. Seppänen<jks@...278...> wrote: