Display page X of Y
What sounds like a simple task is actually quite complicated in NAV. This recipe will show you how to print the total number of pages on every page of a report.
Getting ready
You must have PDFCreator installed on your machine. This recipe was tested with version 0.9.8 and 0.9.9, and is not guaranteed to work with future or previous releases of PDFCreator.
You must also have Visual Studio 2005 or later installed on your machine in order to write the C# code for this recipe.
How to do it...
Create a new class library project named
NAVUtilities
in Visual Studio.Add a new file called
PDFPageCounter
with the following code:using System.IO; using System.Text.RegularExpressions; using System.Runtime.InteropServices; namespace NAVUtilities { [ClassInterface(ClassInterfaceType.AutoDual)] [ProgId("PDFPageCounter")] [ComVisible(true)] public class PDFPageCounter { public int GetNoOfPagesPDF(string FileName) { int result = 0; FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess...