Reset footnote numbers per page, PDF

35 views
Skip to first unread message

n7...@earthlink.net

unread,
Jun 23, 2023, 2:48:36 AM6/23/23
to DITA-OT Users
I'm using FOP for pdf2 output and I want to reset footnote numbers after every page, so that page 1 has footnotes 1 through 4, page 2 has footnotes 1 and 2, page 3 has footnotes 1-6, and so on. Using OT v2.5.4, I don't see a parameter for this kind of thing.

Do I need to do something like hack the FOP area tree to do this?

Thanks,
Mark

n7...@earthlink.net

unread,
Jul 9, 2023, 2:56:28 AM7/9/23
to DITA-OT Users
I answered this question to my satisfaction myself. If I am incorrect below I'd love to hear it.

It does appear that there is no way to reset the footnote numbers on every page with a DITA OT parameter or something easy like that. And because an XSL-FO processor like FOP assigns automatic page numbers on the fly, you can't do this with XSL-FO. But the FOP area tree does include the page breaks that it has calculated, and you can get FOP to dump the area tree to the file system as an XML file, modify it, and read it back into FOP to produce the PDF.

Except FOP failed each time I tried to read the area tree back in. Then I discovered that there is another structure FOP creates called "Intermediate Format". I could output that as an XML file, modify it (to reset footnote numbers for every page) and successfully read it back in to produce a PDF. So that worked. Someone on the fop-users email list told me that the FOP area tree "is maintained only for unit tests, its missing many features so shouldn’t be used by a end user." So that is another reason to use Intermediate Format ("IF").

There is not much that I could find in the way of documentation for the area tree or Intermediate Format. And I was using the command line and had to decipher how to run what I needed, trial and error. Here's my FOP command line in Powershell:

# output IF to XML file if.xml
.\fop -fo .\topic.fo -if if.xml

# modify file here (you have to figure out the structure unless you find some docs I couldn't find)

# output PDF from if.xml after changing it:
.\fop -ifin .\if.xml -pdf mypdf.pdf

I also tried this in Antenna House, and it also calls it the "area tree". The AH docs are more thorough but it still requires slogging. Here are my command lines in Windows cmd.exe:

# output area tree to XML file
ahfcmd -d topic.fo -o areatree.xml -p @AreaTree

# modify file here (figure out the area tree structure, some docs here: https://github.com/AntennaHouse/AreaTree and here: https://antennahouse.github.io/AreaTree/en/)

# output PDF from areatree.xml after changing it:
ahfcmd -d areatree.xml -o mypdf.pdf

And there you have it.

Mark Giffin


Chris Papademetrious

unread,
Jul 10, 2023, 9:18:23 AM7/10/23
to DITA-OT Users
Hi Mark,

Even though we don't use XSL-FO for PDF generation, I enjoyed reading your post. It was well-structured and easy to understand. Thanks for sharing the outcome.

 - Chris

n7...@earthlink.net

unread,
Jul 10, 2023, 7:50:55 PM7/10/23
to DITA-OT Users
Thanks Chris and you're welcome. I figure someone can probably use this sometime. In the past I've even posted something like this, and then a couple years later run into the same problem, and end up finding my own post because I forgot!

Mark

Reply all
Reply to author
Forward
0 new messages