How to get total page count printing multiple sheet spread to pdf ?

Posted by: wilfried-fp on 8 September 2017, 2:48 pm EST

  • Posted 8 September 2017, 2:48 pm EST

    I have a spread with multiple sheets to be printed to one pdf; the page count before printing is not known, because some of them need more than 1 page. I found the way to get the page count of a single sheet, but not of the whole spread.
    For the page count of the sheet I used the following code: <FONT size=2>

    fpMappe.Sheets(i).PrintInfo.Header = </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"/ds"</FONT></FONT><FONT size=2> & </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"/c"</FONT></FONT><FONT size=2> & fpMappe.Sheets(i).SheetName & </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" Page /p"</FONT></FONT><FONT size=2> & </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" of /pc"</FONT></FONT>

    <FONT size=2><FONT size=2><FONT color=#000000>I need the total page count (this could work with adding the values of "Spread.<FONT size=2>GetPrintPageCount(sheetindex)"</FONT>) </FONT></FONT></FONT>

    <FONT size=2><FONT size=2><FONT color=#000000>but I also need the pageNr relative to the total page count (</FONT><FONT color=#a31515> /p is only the number within ONE sheet)</FONT></FONT></FONT>

    <FONT size=2><FONT size=2> </FONT></FONT><FONT size=2><FONT size=2>Thanks, wilfried




  • Replied 8 September 2017, 2:48 pm EST

    Sorry, found the solution by myself:

    Dim totalPagesL As Integer = 0
    Dim actPageNrL As Integer = 1
    Dim actPagesL As Integer = 0
    For i As Int32 = 0 To fpMappe.Sheets.Count - 1
                actPagesL = fpMappe.GetPrintPageCount(i)
                totalPagesL += actPagesL
                fpMappe.Sheets(i).PrintInfo.FirstPageNumber = actPageNrL
                actPageNrL += actPagesL
    For i As Int32 = 0 To fpMappe.Sheets.Count - 1
         fpMappe.Sheets(i).PrintInfo.Header ="Page /p" & " of " & totalPagesL.ToString

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels