Printing with EPL language

Hi everyone.

I will really appreciate some help with the next issue.

I’m receiving an EPL instruction through a WebService, which I am saving into a BLOL field. I need to send that instruction into a known printer, not the default one. Is there any known instruction todo this, or I should use any type of library? May be Zebra?

Thank you very much

Can you do this from a command line ?

NET USE LPT1: \computername\printersharename /persistent:yes
PRINT /D:LPT1 C:\MYFILE.EPL

IF I am not remembering it wrong then you should also be possible to do a

COPY /B MYFILE.EPL LPT1

First of all, thanks for your answer Palle.

What I understand from your tip, is that I should create and EPL file (phisically), and send it to the printer? Must say that the LPE instruction is saved into a blobl field. I solved a similar issue sending a PDF to a printer, from a blob, this way:

   //save PDF into directory
lShipment.CALCFIELDS(Sticker);
lTmpBLob.Blob := lShipment.Sticker;
lTempServerFileName := lFileManagement.ServerTempFileName('.pdf');
lFileManagement.BLOBExportToServerFile(lTmpBLob,lTempServerFileName);
FileNameServer := '\\SRV-DC01\navision\XML\Pegatinas\'+lShipment."No."+'.pdf'; 
lFileManagement.DownloadToFile(lTempServerFileName,  FileNameServer);

// //  //Send PDf to the printer
Printer := Printer.PdfFilePrinter(FileNameServer);
Printer.DefaultPrinterName := 'Etiquetas Expediciones 2';
Printer.AdobeReaderPath('C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe');
Printer.Print();

Should be something similar to this? Or may be using “ProcessStartInfo”?

IF ISNULL(ProcessStartInfo) THEN
    ProcessStartInfo := ProcessStartInfo.ProcessStartInfo;
  ProcessStartInfo.UseShellExecute := TRUE;
  ProcessStartInfo.Verb := 'print';
  ProcessStartInfo.WindowStyle := ProcessWindowStyle.Hidden;
  //SELECT PRINTER
  ProcessStartInfo.Arguments :='Etiquetas Expediciones 2';
  ProcessStartInfo.FileName := FileNameServer;
  Process.Start(ProcessStartInfo);
  Process.Close;

If instead of that, I use the commands as you say, how could I introduce them into NAV?

Thank you very much again

I have created the EPL file without any problem into the directory, now the only issue is to send it to the printer

YES! the last example is correct - It looks similar to what I do in other situations :slight_smile:

Once saved the EPL file, I’m using this:

   IF ISNULL(ProcessStartInfo) THEN
     ProcessStartInfo := ProcessStartInfo.ProcessStartInfo;
   ProcessStartInfo.UseShellExecute := TRUE;
   ProcessStartInfo.Verb := 'print';
   ProcessStartInfo.WindowStyle := ProcessWindowStyle.Hidden;
   //seleccionar impresora
   ProcessStartInfo.Arguments :='Etiquetas Expediciones 2';
   ProcessStartInfo.FileName := FileNameServer;
   Process.Start(ProcessStartInfo);
   Process.Close;

But I see this error:

inglersd.png

“There os no associated application with the specified file for this operation”

What could be the error?

I create the EPL:

   lShipment.CALCFIELDS(EPL);
   lTmpBLob.Blob := lShipment.EPL;
   lTempServerFileName := lFileManagement.ServerTempFileName('.EPL');
   lFileManagement.BLOBExportToServerFile(lTmpBLob,lTempServerFileName);
   FileNameServer := '\\SRV-DC01\navision\XML\ENVIALIA\Pegatinas\'+lShipment."No."+'.EPL'; 
   lFileManagement.DownloadToFile(lTempServerFileName,  FileNameServer);

It’s the same procedure and code i use to print a PDF I think…

In order to find out where it exactly fails start with manually saving a file in a folder where you are sure you have acces to the folder from the Servicetier

and then try to do the printing

As I don't know what dotnet functions you are using specifically then I cannot see if you are doing it 100 procent right.

I would normally have a

Processstartinfo.Filename :=

Processstartinfo.createnowindows ::= TRUE

Processstartinfo.Windowstyle := Windowstyles.hidden;

processtartinfo.verb := ‘PRINT’

All I CAN say is that your original way of printing PDF-files is something that I would NEVER do - but you know that from previous discussions [emoticon:c4563cd7d5574777a71c318021cbbcc8]

Thanks Palle,

The folder where I’m creating the EPL file, is the same where I WAS creating the PDF(I say was, because this develompent will replaec the one with the PDFs, don’t know if you will like more… ;-)) . And I see the created EPL file, so this part is working good.

THe folder is the same, and the configuration of the ProcessStarInfo is also the same, and looks very similar to the one you’ve recommend to me. May be it’s a problem generated becasue of the EPL file? That it doesn’t work lile a PDF?

Thank you again

Please verify the answer(s), which helped you solve this question.

Hello Erik,

Are you talking about the answers int his post? I think I’m using correctly the instrucions for the ProcessStartInfo, the same way for the PDF,and it was working. May be are you talking about the sheel commands?

I’m also using this link for tips, where we can see the same error I’m having:

http://www.waldo.be/2015/12/21/print-any-document-any-extension/

But hte error persists, I’m thinking that may be could be a compatibility issue of the EPL, becasue it I right click over the EPL file, I don’t see the “print” option…

I am just asking you to click on the “Verify Answer” button, I’m not the one with the question…

Of course I will verify his answer, it’s being really helpful. But the problem is that I still have that small (but really important) problem, and if I mark the post as solved, I won’t have more help with this issue,

Seems to be an issue with the EPL, if I create the file in text mode, I don’t get the error…

Does it work if you do a copy /b yourfile.epl to to printer?

How should I do that? It seems that the SHELLcommand can’t be used…

I asigned the Notepad++ as the default aplication for the epl files, and remains equal. I don’t have the “print” option if I right click onto the file, and that seems to be the problem. If in the verb I use “open” instead of “print”, I don’t find that error, so I think that the problem can come from there…

You are trying to do everything in one go, without knowing if you are close to reach your goal. That is why i suggested you to split it into smaller tests.

  1. Can you create a proper file and save it to a folder

  2. Can you do a manual print of that file (this is what i want you to do now)

  3. test that it works in one go.

So can you do a

NET USE LPT1: \computername\printersharename /persistent:yes
PRINT /D:LPT1 C:\MYFILE.EPL

and second try

COPY /B MYFILE.EPL LPT1

No Palle, I cannot print the file manually. That’s why I first try assigned the default application, hopping that to be solved. If now I open the file with notepad++ (the default app), I can’t print if from inside the app, but as a “text file”. I still don’t having the “print” option in the right click, which is supposely what we are emulating with the “ProcessStartInfo” development.

Of course, the file is properly saved in the drectory

Well it is soo hard to find out what goes wrong in code if you cannot do it manually step by step. It has nothing to do with NotePad++ Besides from that Notepad++ is not designed for printing but development. And as a sidenote you should use Visual Studio Code editor instead (Code.Visualstudio.com) - as this is the new Dynamics NAV development “environment”.

You have to solve the printing issue first. So you can verify that your EPL-file is working. RIght now you have no idea of where you are sending your EPL file to for printing.

Do you have the printerdriver installed? and what port/name etc is it?

it is ALWAYSS possible to do a PRINT of a file. If you dont get the PRINT from command prompt to work, then you will never get it to work in code.

About the printDriver… In our customer’s server, It has 8 different printers installed. I think that he has a few drivers installed… I’l try to figure out hoy to print from command line, and see waht happens…

I’m trying to use this:

NET USE LPT1:  '\\SRV-DC01\Etiquetas Expediciones 2'  /persistent:yes

And I get this error:

“Device name is not valid”

This issue is driving me mad. I am always self-learning, and I getting really desperate because I know that with a few more knowledgement this should be a quite easy question…

This is the configuration of the printer:

What am I doing wrong?