1 2 Previous Next 16 Replies Latest reply on Jan 12, 2015 6:29 AM by edpod2101

    Printing barcode labels on a Zebra printer using ZPL commands.

    edpod2101

      I need to generate labels on a Zebra printer using embedded print commands (ZPL). A single windows pc generates the labels with a locally attached (USB) Zebra GK420t printer. I know of no way to send raw data directly to a printer from FM, i.e. a data file with embedded ZPL commands. I can generate a file containing the ZPL commands and the label data and export it as a .txt file.  But I need to automate the print process so the user simply presses the Print Labels button.


      Anyone have experience with printing using ZPL or sending a raw file directly to a printer.  The app is built on FM 13 Server.


      I would appreciate any guidance. Thanks


      Ed

        • 1. Re: Printing barcode labels on a Zebra printer using ZPL commands.

          I don't recall the name right this moment but there is a FileMaker plugin that creates barcodes from the numbers in your field. I believe they are small graphics. I was able to print those to a zebra printer directly from the container field with the print command. I think I also could use a bar code font to do this. I know I did with a laser printer.

           

          I avoided any complexity by just using the container field on the layout and the printing to the attached printer with the Print command.

          • 2. Re: Printing barcode labels on a Zebra printer using ZPL commands.
            lderuntz

            Setup your USB printer to use the does LPT: port.  Look online for connecting it, or follow the windows instructions.

             

            Generate your ZPL as an exported text file.

            Then execute a batch file with Send Event that pipes that text to the LPT port, like Type FILE.TXT > LPT1

            Printing DOS output to printer

            • 3. Re: Printing barcode labels on a Zebra printer using ZPL commands.
              domiller

              I am a big fan of the 360Works ScriptMaster plugin.  If you haven't tried it, you should.  Having said that, here is my solution for printing to a Zebra using the aforementioned plugin.  I'm using EPL rather than ZPL, but the structure of the code is the same.  This may be *too* much information, but it may prove useful to someone.

               

              #=================================================================================

              # Script; Print to Zebra Printer

              # Parameter: A |-separated list of up to four lines to be printed and a fifth element with a UPC.

              # Assumptions: $$LabelPrinter MAY be set to override the default

              # Note 1: If $$LabelPrinter is set, it will override the default of \\localhost\labels

              # Note 2: This script will only perform properly on Windows, not Mac

              #=================================================================================

               

              If IsEmpty($$LabelPrinter)

              Then

                  Set Variable $LabelPrinter = "\\\\localhost\Labels"

              Else

                  Set Variable $LabelPrinter = $$LabelPrinter

              End If

              # Retrieve all the information to be printed

              Set Variable $inputs = Substitute(Get(ScriptParameter);"|";¶)

              Set Variable $Line1 = GetValue($Inputs;1)

              Set Variable $Line2 = GetValue($Inputs;2)

              Set Variable $Line3 = GetValue($Inputs;3)

              Set Variable $Line4 = GetValue($Inputs;4)

              Set Variable $UPC = GetValue($Inputs;5)

              #

              #

              # Select the printer using the stored function that should have been loaded at startup.

              # First, force LPT1 to be unassociated.  We don't check return code on this because we don't care.

              Set Variable $result = RunShellScript("net use LPT1: /d";"True";10)

              # Now set the printer association

              Set Variable $result = RunShellScript("net use LPT1: " & $LabelPrinter;"True";10)

              If $result = "ERROR"

              True

                  Show Custom Dialog "There was an error connecting to your label printer.  Please try again or contact your systems administrator"

                  Exit Script

              End If

              # Actually send the data to the printer.

              Set Variable $ToExecute =

                  "

                  FileOutputStream os = new FileOutputStream(\"LPT1\");

                  PrintStream ps = new PrintStream(os);

                  ps.println('N');

                  ps.println('A50,0,0,1,1,1,N,\"" & $Line1 & "\"');

                  ps.println('A50,30,0,1,1,1,N,\"" & $Line2 & "\"');

                  ps.println('A50,60,0,1,1,1,N,\"" & $Line3 & "\"');

                  ps.println('A50,90,0,1,1,1,N,\"" & $Line4 & "\"');

                  ps.println('B50,120,0,UA0,2,4,50,B,\"" & $UPC & "\"');

                  ps.println('P1');

                  ps.close();"

              Set Variable $result = EvaluateGroovy($ToExecute)

              # Clean up after our self.

              Set Variable $result = RunShellScript("net use LPT1: /d";"True";10)

              Exit Script

              • 4. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                dhuebsch

                We are using CNSPlugins Barcode plugin, which I believe disabled_jackrodgers was referring to.  It works well, however, the plugin needs to be loaded for each user.  It creates a png inside a container field for the barcode, which you can place anywhere on a layout.  The nice part is it is printer independent (we have a mix of Zebra, Datamax, Avery and Intermec).  The down side is since it is a plugin, it does not work with FM Go. 

                 

                We are trying to move past this limitation, so if anyone knows of a way to do this from FM Go, please let me know.

                • 5. Re: Printing barcode labels on a Zebra printer using ZPL commands.

                  The is a CNS Barcode app for Go but I could not find it with a search in

                  the App Store. A Google search found the web page

                   

                  https://www.cnsplug-ins.com/iOS/CNS_Barcode/FAQs

                  • 6. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                    dhuebsch

                    That app is for scanning barcodes only within the app.  You can send the barcode, once scanned to FM, but you cannot generate barcodes from within FM to print.

                    • 7. Re: Printing barcode labels on a Zebra printer using ZPL commands.

                      CNS Barcode is available as an app but a search of the apps store will not

                      find it, strange.

                       

                      https://www.cnsplug-ins.com/iOS/CNS_Barcode

                      https://itunes.apple.com/us/app/cns-barcode/id395773769?mt=8

                       

                      However, read the notice about how it works.

                       

                      And you can generate barcodes using FileMaker Pro and it has been a while

                      so I can't say about Go.

                       

                      It reads, generates in choice of flavor and prints. My favorite is the 3D

                      barcode for the amount of data you can store in it.

                      • 8. Re: Printing barcode labels on a Zebra printer using ZPL commands.

                        Perhaps the Go version does not generate bar codes, it has been a while.

                        but the Pro version definitely does and costs a bit more. Generate in Pro,

                        read and print in Go.

                         

                        I created a PDF file of an inventory list using Pro and CNS Barcode that I

                        could scan from my computer screen using my iPad...:)

                         

                        I could create a 3D barcode saved to a PDF file that would contain a lot of

                        information. If I wanted to privatize it I could first encode the info in

                        my text field and then create a bar code from that and decode it into a

                        field when scanned.

                         

                        Using a bar code font also works if you are careful.

                        • 9. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                          edpod2101

                          Thanks for replying.  All are helpful in finding a solution.  I am currently replacing an application written in Visual Basic that writes the text file directly to the Zebra printer to produce these labels.  It seems that it is easy to do this in Visual Basic.  The FM solution that will replace this system will provide much more function but unfortunately it doesn't make the label printing easy.

                           

                          The downside to keeping the barcodes in FM and then printing labels with FM is that the label is small.  The ZPL commands allow you to very nicely reduce the fonts for the text information above and below the barcode.  I tried doing this directly with FM using a barcode font.  I never was able to get all the information on the label.  I'm not sure all of it is needed but you can't take something away from a user, so it stays as is.

                           

                          I created a file with the data and embedded ZPL commands and exported it as a text file.  I used the Zebra print tools to manually send that file to the printer and was successful in printing the labels.  So I need to automate this function, i.e. write a windows script, and execute that function inside of FM.  I haven't written shell scripts before so I guess I will learn something new.  Your suggestions have pointed me in the right direction.  I will also check out the plug-ins that you mentions.

                           

                          So I'm still trying to make it work.

                          • 10. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                            domiller

                            I will again put in my plug for the (Free!) Scriptmaster plugin.  With it and the code provided above you don't have to mess with windows scripts.  Just generate up the text to send to the printer and send it out.  Since it sounds like you already have the ZPL generated, the hard part is done.

                            • 11. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                              edpod2101

                              Thanks.  I'm going to check it out right now.  While I'm always up for learning something new, I'll always opt for not reinventing the wheel.  I will try it this weekend and let you know.

                               

                              Ed

                              • 12. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                                jbante

                                Barcode Creator is another tool for generating barcode images that you can store in container fields. It works in all deployments of FileMaker 13 (Go, Pro, Advanced, Server, WebDirect), and you don't have to do any URL-based app switching on iOS. Disclosure: I wrote it.

                                 

                                However, it would seem like a shame to not take advantage of the barcoding features of ZPL that you already have.

                                • 13. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                                  edpod2101

                                  It seems like I am close to resolving this but its like running on a treadmill.  I am not very deep in windows so maybe I'm not as close as I thought.  I'm looking at ScriptMaster and it does appear to be a component of the solution.  I'm trying to run the commands manually first to make sure my labels print.  Then create a script executed with ScriptMaster.

                                   

                                  I know that I am communicating with the printer as I can use the Zebra print driver tools to send my formatted ZPL/data file to my printer.  Barcoded labels are produced.  But nothing when I send the file through other commands, i.e. print, copy, type, get-content, out-printer.  I am either getting a dialog that shows me thousands of pages being generated (I only sent 1 label so this is obviously an error), or a reply telling it went to the printer with no output, or an error. 

                                   

                                  I believe the problem is that the Zebra is connected to the local PC using a USB connection.  Everything I am reading tells me that I need to be directing the print to LPTx.  I tried to redirect to LPT1 with the net use command but I keep getting a network resource error (66).  I am a novice at shell scripting so I have run up against a wall.

                                   

                                  Can you offer any guidance regarding the redirect to LPT1?

                                   

                                  Thanks again,

                                  Ed

                                  • 14. Re: Printing barcode labels on a Zebra printer using ZPL commands.
                                    domiller

                                    Make sure that the printer in question is shared and can be seen when you try a "net view" command.  I'm presuming that the printer is physically connected to your local machine.  Try the command "net view \\localhost".  That should show you the share name.  If it doesn't, go back and check the print queue sharing.  In my case, the print queue is name "labels", so I see results like this:

                                    ---------------------------------------------------------------------------------------------------------------

                                    Shared resources at \\localhost

                                    Share name                Type   Used as  Comment

                                    ----------------------------------------------------------

                                    Brother HL-2270DW series  Print           HL-2270DW LAN

                                    C                         Disk

                                    D                         Disk

                                    Labels                  Print           Labels

                                    Users                   Disk

                                    -----------------------------------------------------------------------------------------------------------------

                                    Then I use the command "net use lpt1: \\localhost\Labels" to make the association.

                                     

                                    One caveat:  I have seen issues with print queues trying to reformat plain text into something else.  If that is the problem, create a print queue pointing to the USB device, but do *not* define it as a Zebra printer.  Instead, select Generic/Text Only as the device type.  This ensures that a text file will be passed through unmolested.

                                     

                                    All-in-all, windows print queues have both good and bad points, and lack of ability to easily send a raw file to a printer counts among the bad points.

                                     

                                    Oh, and I just remembered one other issue:  Make sure your machine doesn't already *have* an LPT1 port!  If you do, you can use any of LPT2 through LPT9 the same way.

                                    1 2 Previous Next