header and footer with rst markup

356 views
Skip to first unread message

Troy Sorzano

unread,
Mar 31, 2010, 1:27:51 PM3/31/10
to rst2pdf-discuss
I found rst2pdf while researching ways to generate simple pdf
documents. WOW this is a great tool. I am using the "replace" rst
markup so I have one text file with my "data" dynamically generated
and one text file with my "content". I ran into one issue using
replace and bold in headers and footers.

|QuoteNumber| works as long as it is in my rst content. It will get
replaced with the actual InvoiceNumber.

**my bold text** works as long as it is in my rst content.

However if I use the markup in a footer or header. It will actually
print "|QuoteNumber|" and "**my bold text**".

Here is my style
defaultFooter : |QuoteNumber| **Customer Initials:**_______
Date:_______ Page ###Page### of 4

Also is there any variable for total pages? I would like to use Page
###Page### of ###TotalPages###

Thanks for any pointers.

Troy

Roberto Alsina

unread,
Mar 31, 2010, 1:42:27 PM3/31/10
to rst2pdf...@googlegroups.com
On Wednesday 31 March 2010 14:27:51 Troy Sorzano wrote:
> I found rst2pdf while researching ways to generate simple pdf
> documents. WOW this is a great tool. I am using the "replace" rst
> markup so I have one text file with my "data" dynamically generated
> and one text file with my "content". I ran into one issue using
> replace and bold in headers and footers.
>
> |QuoteNumber| works as long as it is in my rst content. It will get
>
> replaced with the actual InvoiceNumber.
>
> **my bold text** works as long as it is in my rst content.
>
> However if I use the markup in a footer or header. It will actually
> print "|QuoteNumber|" and "**my bold text**".

I tried it with this file and it works (current SVN):

.. header::

I recommend you try |Python|.

.. footer::

I recommend you try |Python|.

I recommend you try |Python|.

.. |Python| replace:: Python, *the best language* around


--------------------

Maybe you can share a failing file? I'll be happy to test it!


> Here is my style
> defaultFooter : |QuoteNumber| **Customer Initials:**_______
> Date:_______ Page ###Page### of 4
>
> Also is there any variable for total pages? I would like to use Page
> ###Page### of ###TotalPages###

In 0.14 and later you can use ###Total###

Troy Sorzano

unread,
Apr 1, 2010, 9:33:12 AM4/1/10
to rst2pdf-discuss
On Mar 31, 1:42 pm, Roberto Alsina <rals...@netmanagers.com.ar> wrote:
>
> I tried it with this file and it works (current SVN):
>
> .. header::
>
> I recommend you try |Python|.
>
> .. footer::
>
> I recommend you try |Python|.
>
> I recommend you try |Python|.
>
> .. |Python| replace:: Python, *the best language* around
>
> --------------------
>
> Maybe you can share a failing file? I'll be happy to test it!

Yes your example works with the header and footer in the rst
document. I was trying to use the stylesheet which did not work.

st.style

pageTemplates:
cutePage:
frames: []
[0%, 0%, 100%, 100%]
showHeader : true
showFooter : true
defaultHeader : "|Python| **Customer Initials:**_______
Date:_______ Page ###Page### of ###Total###"
defaultFooter : "|Python| **Customer Initials:**_______
Date:_______ Page ###Page### of ###Total###"

st.txt

I recommend you try |Python|.

.. |Python| replace:: Python, **the best language** around


http://groups.google.com/group/rst2pdf-discuss/web/st-example.zip

I was expecting the |Python| to be replaced and the "Customer
Initial:" to be in bold. This is not a major issue for me as I can
use the header and footer in the rst content. I just assumed it would
work in the style sheet.

> > Also is there any variable for total pages? I would like to use Page
> > ###Page### of ###TotalPages###
>
> In 0.14 and later you can use ###Total###

Thank you ###Total### is what I was looking for and it works.

Troy

Roberto Alsina

unread,
Apr 1, 2010, 10:53:52 AM4/1/10
to rst2pdf...@googlegroups.com
On Thursday 01 April 2010 10:33:12 Troy Sorzano wrote:
> Yes your example works with the header and footer in the rst
> document. I was trying to use the stylesheet which did not work.

Ok then, I'll test it but it's probably a bug. The header/footer stuff is not
the easiest part of rst2pdf :-(

Roberto Alsina

unread,
Apr 2, 2010, 11:20:53 AM4/2/10
to rst2pdf...@googlegroups.com
On Thursday 01 April 2010 10:33:12 Troy Sorzano wrote:

It should, it's a bug, thanks for the report!

I have entered it as Issue 307:

http://code.google.com/p/rst2pdf/issues/detail?id=307

You can "star" that issue and get notified by mail of any progress,

There is now also a test case in the test suite, and I will take a look at it
ASAP.

Roberto Alsina

unread,
Jun 9, 2010, 5:34:33 PM6/9/10
to rst2pdf...@googlegroups.com
It took a while (2 months), but I have just fixed the bug reported in this
thread, Issue 307: http://code.google.com/p/rst2pdf/issues/detail?id=307

To make a long story short: Now you can define headers and footers in the
stylesheet using any markup that would work in the main document.

For example, you can use in the header an image substitution defined in the
document body, and it should work.

Best regards,

Reply all
Reply to author
Forward
0 new messages