Currently it is not possible in NAV to detect the ouputtype of an Report in NAV (Print, PDF, HTML, EXCEL).
A Possible solution
In older NAV version I created a SetPdfPrint and IsOdfPrint method in an „Single Instance“ codeunit and before the REPORT.SAVEASPDF(…) method is called I call the SetPdfPrint(TRUE) method and after the print I call the SetPdfPrint(FALSE).
But in this scenario it is possible that the report thors and error and the flag ist still set in the single instance codeunit.
The better solution
With NAV2016 we have now TryFunction. If an error is thrown it will not rollback the current transaction and then we can take a lock into the callstack 😉
So I created a codeunit „Detect Output Type“:
First of all I throw an empty error, now I have access to the error callstack and can check there I come from.
In the callstack I search for the word ‚SaveAsPDF‘. This function is used by the ReportDistributionManagement.
Now we can call DetectOutputType.IsPdfPrint from our report.