I’m trying to print a PDF that has been previously created in a folder. At the moment, I’m trying to do it from the server, running the RTC in the client, saving the PDF in the server, and trying to print like this:
IF ISNULL(ProcessStartInfo) THEN
ProcessStartInfo := ProcessStartInfo.ProcessStartInfo;
ProcessStartInfo.UseShellExecute := TRUE;
ProcessStartInfo.Verb := 'print';
ProcessStartInfo.WindowStyle := ProcessWindowStyle.Hidden;
//seleccionar impresora
ProcessStartInfo.Arguments :='\\SRV-DC01\Etiqueta Expediciones';
ProcessStartInfo.FileName := FileName;
Process.Start(ProcessStartInfo);
MESSAGE('Etiqueta enviada a impresora');
With this code, I’m just ablle to print from the default printer. “SRV-DC01” is the server name. Should I use the domain name? OR may be the IP? At the end, the development will be executed from the RTCs installed in different laptops, in the same network.
Remember that even when you run this code from the RTC Windows client, then the process is still executed on the NAV server by the service user. So it has to be a printer, that the service user has access to. And the same goes in regards to the folder with your PDF. It is relative to the server, not the client. And you need to upload any local files to the server from the client first, if the service user has no access.
I found that issue you are talking, about he server side, for example, when I’m generating different XML files. The XMLport runs in server side, but I’ve solved that issue using a folder shared in the network.
My idea is to create the PDF files in the local machines, and call to the printer the way I’ve wrote in the code…
You have to remember the client does NOTHING! Think of it like this. If you have access to NAV using a webclient it still works, meaning that everything is done by the SERVER (The NAV servicetier). So the Servicetier user has to have the permission to see the printer and use the printer.
What .NET are you using? (ProcessStartInfo-variable). Because there are more than one you could use.
It simply means that the “user” that runs the Servicetier has to have permission access to the printer.
If you are running the servicetier as the account “Network Service” then you cannot print… Again it is NOT the user logged into NAV that does the printing. It is the Servietier…
Yes everything is done on the server. The RTC is really not much more than a web browser, it’s only your user interface. When you print a report then RTC communicates with your printer directly, but otherwise not.
I must say that the NAV instance is running with a server account, called “administrator”. So, how can I reach the printer from the server? This is how the printers are declared on the server:
The printers declaired on the server is not necessary the same the “administrator” user can see. In your code you should use the \ip-adress\name or \server\printername in order to print.
There are many unknown variables in this, som it is hard to help you as we do not have the full view of your configuration.
It is possible to get it to work. But you could also go in another direction:
A faster solution could be to copy files to a specific folder - where a service picks up the file and prints it. There are several programs that can do that for you.
You could also create a powershell script. Like this one:
The main problem is that, I get the PDF file from a webService, and I need to print it. If I could “introduce” the PDF into a report, the problem will be solved with the report selection table, but I dpn’t know if it is possible to do that…