Printing a PDF Document together with a Dynamics Nav Report

Hi Guys

I have a PDF Document sitting on my NAV server which I want to print each time I print an invoice from Nav. I have written a function to print the document using the default PDF program installed on each machine. The problem is that it prints sometimes and it does not print in other instances.

Does anyone have a better idea on how to do this without modifying the report?

Thanks you all

Can you show us the code in your function and where did you write?

It would be great if you could just paste the code written for printing the pdf report.

REATE(objShell);
IF NOT EXISTS(PrintThisFile) THEN
MESSAGE(‘Text50001’);
EXIT;
SplitDirFile(PrintThisFile,Dir,Filename);
objFolder := objShell.NameSpace(Dir);
objFolderItems := objFolder.Items;
objFolderItem := objFolderItems.Item(Filename);
objVerbs := objFolderItem.Verbs;
i:=-1;
REPEAT
i+=1;
IF i<objVerbs.Count THEN
objVerb := objVerbs.Item(i);
UNTIL (STRPOS(UPPERCASE(objVerb.Name),‘PRINT’)>0) OR (i >=objVerbs.Count);
IF i<=objVerbs.Count THEN BEGIN
objVerb.DoIt;
END ELSE
ERROR(Text50001, Filename);

SplitDirFile(PrintThisFile : Text[250];VAR Dir : Text[250];VAR Filename : Text[250])

ExitLoop := FALSE;
PointBreak := STRLEN(PrintThisFile);
WHILE (NOT ExitLoop) OR (PointBreak <= 1) DO
IF COPYSTR(PrintThisFile,PointBreak,1) = ‘’ THEN BEGIN
Filename := COPYSTR(PrintThisFile,PointBreak + 1);
ExitLoop := TRUE;
END ELSE
PointBreak -= 1;
Dir := COPYSTR(PrintThisFile,1,PointBreak);