Search code examples
reporting-servicespaginationpdf-generationsql-server-2014ssrs-2014

SSRS page numbers incorrect in pdf format


I am generating a SSRS report from SQL2014.

The report renders correctly when looked at in the Report Builder preview, but when exported to pdf the report numbers are incorrect.

In my test report there are three "reports" each 1 page long. So each page should be page 1 of 1, but the middle page ends up being page 2 of 1.

If I print a report with just 1 multi page "Report" the page numbers work fine.

I'm using what I think is a standard expression for page numbers:

=Globals!PageNumber & " of " & Globals!TotalPages

I see the same issue when I export to tiff.


Solution

  • I ended up using this function from msdn

     Shared offset as Integer
     Shared currentgroup as Object
    
     Public Function GetGroupPageNumber(group as Object, pagenumber as Integer) as Object
      If Not (group = currentgroup)
         offset = pagenumber – 1
         currentgroup = group
      End If
    
      Return pagenumber – offset
     End Function
    

    Along with the tablix member to name the page based on the group by setting the PageName property under Group to the ID of my group, then using the following expression for my totals, and to reset the page nums:

    =Code.GetGroupPageNumber(Globals!PageName, Globals!PageNumber) & " of " & Globals!TotalPages
    

    Seems to get me out of the wood, I'm not sure if its the "right" way to do it though.