Pooja
Pooja

Reputation: 119

How to get the total page count of an AFP/PDF to a .txt file in XSL FO

I am using Apache fop to generate AFP and PDF files. Everything works perfectly fine and i am struggling with one thing.

I am able to get the total page count of each file using :

<fo:block text-align="right">
        Page <fo:page-number/> of <fo:page-number-citation-last ref-id="end"/>
</fo:block>

It works perfect on both AFP and PDF.

But there is one other thing im trying to achieve - getting this total page count in a .txt file. I am using result-document to create a .txt file:

<xsl:result-document href="{$FileName}.txt" method="text">
            <xsl:value-of select="'abc'"/>
</xsl:result-document>

Here, i would like to have the total page count of the file. How do i achieve this?

Upvotes: -1

Views: 56

Answers (1)

Tony Graham
Tony Graham

Reputation: 8068

You may be able to extract the page count from the FOP log when written to a text file. (Not a FOP user, so can't confirm.)

Alternatively, you could run 'pdfinfo' [1][2] or a similar command-line utility on the PDF to get the page count.

[1] https://superuser.com/questions/403672/how-to-count-pages-in-multiple-pdf-files

[2] https://manpages.debian.org/jessie/poppler-utils/pdfinfo.1.en.html

Upvotes: 1

Related Questions