# Selecting an specific print to print a PDF

**URL:** <https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077>\
**Category:** Developers Forum\
**Created:** [September 26, 2018, 10:38am UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077 "2018-09-26T10:38:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [September 26, 2018, 10:38am UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/1 "2018-09-26T10:38:34Z")

</div>

Hi everyone,

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:

```auto
  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.

Thank you very much

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [September 26, 2018, 11:22am UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/2 "2018-09-26T11:22:49Z")

</div>

Which version of NAV?

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.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [September 26, 2018, 12:18pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/3 "2018-09-26T12:18:39Z")

</div>

I am using NAV 2018.

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…

---

<div class="post-metadata">

**Author:** ![PalleA](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PalleA](https://www.dynamicsuser.net/u/PalleA)\
**Post date:** [September 26, 2018, 12:21pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/4 "2018-09-26T12:21:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [September 26, 2018, 12:24pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/5 "2018-09-26T12:24:20Z")

</div>

So, the printers should be defind and configured in the server side? Doesn’t mind how the are configured in the laptop with the RTC?

---

<div class="post-metadata">

**Author:** ![PalleA](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PalleA](https://www.dynamicsuser.net/u/PalleA)\
**Post date:** [September 26, 2018, 12:47pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/6 "2018-09-26T12:47:08Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [September 26, 2018, 1:14pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/7 "2018-09-26T13:14:02Z")

</div>

> [@](#):
>
> So, the printers should be defind and configured in the server side? Doesn’t mind how the are configured in the laptop with the RTC?

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.

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [September 26, 2018, 1:45pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/8 "2018-09-26T13:45:53Z")

</div>

Thank you both.

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:

 ![impresoras.png](https://us1.discourse-cdn.com/flex023/uploads/dugusers/original/2X/7/79e7a5ed789898b6a3261875f5ba4dda95a807e6.png)

---

<div class="post-metadata">

**Author:** ![PalleA](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PalleA](https://www.dynamicsuser.net/u/PalleA)\
**Post date:** [September 26, 2018, 2:21pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/9 "2018-09-26T14:21:50Z")

</div>

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:

[https://gregcaporale.wordpress.com/2012/01/18/powershell-to-print-files-automatically/](https://gregcaporale.wordpress.com/2012/01/18/powershell-to-print-files-automatically/)

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [September 26, 2018, 2:22pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/10 "2018-09-26T14:22:44Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![aitorNAV](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@aitorNAV](https://www.dynamicsuser.net/u/aitorNAV)\
**Post date:** [September 27, 2018, 1:29pm UTC](https://www.dynamicsuser.net/t/selecting-an-specific-print-to-print-a-pdf/66077/11 "2018-09-27T13:29:57Z")

</div>

I’ve solved it using the PDFSharp library

```auto
  Printer := Printer.PdfFilePrinter(FileNameServer);
  Printer.DefaultPrinterName := 'Etiquetas Expediciones 2';
  Printer.AdobeReaderPath('C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe');
  Printer.Print();

```

Also must say that the printer configuration in our customer’s server wasn’t totally correct…

Now my issue is to rotate the PDF before sending to the printer, next challenge!
