Genpdf - print X/Y

I am trying to achieve page X/Y functionality.
Is anyone aware of how to get the total page count?
https://git.sr.ht/~ireas/genpdf-rs/tree/master/examples/demo.rs

This is the code that prints the page number if it exceeds more than 1.

 decorator.set_header(|page| {
        let mut layout = elements::LinearLayout::vertical();
        if page > 1 {
            layout.push(
                elements::Paragraph::new(format!("Page {}", page)).aligned(Alignment::Center),
            );
            layout.push(elements::Break::new(1));
        }
        layout.styled(style::Style::new().with_font_size(10))
    });
    doc.set_page_decorator(decorator);

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.