Italian Stampare etichette con stampante Zebra Usb

Star-Dust

Expert
Licensed User
Longtime User

 

Star-Dust

Expert
Licensed User
Longtime User
Domani provo con la mia stampante. Ho fatto il vaccino e sono un pò fuori uso
 

TILogistic

Expert
Licensed User
Longtime User
Il mio problema e' che non vedo la stampante usb, se faccio
Printer.Initialize("") non mi fa vedere la lista delĺe stampanti .

' "" = Mostrar lista
Public Sub Initialize(printer As String)
printerGen = printer
End Sub
Hai una stampante collegata al tuo pc?
Ha i driver della stampante installati?
Oppure vuoi collegarlo senza driver alla porta USB?
 

Xfood

Expert
Licensed User
Hai una stampante collegata al tuo pc?
Ha i driver della stampante installati?
Oppure vuoi collegarlo senza driver alla porta USB?
Mi piacerebbe provare le due soluzioni, in ogni caso ho collegato la stampante in usb, installato driver, e tramite zebra label riesco a stampare.
Vorrei stampare da b4j creando un'etichetta con i comandi ZPL.
 

TILogistic

Expert
Licensed User
Longtime User
Quale modello di stampante?
È configurato per i comandi ZPL o CPL?

Pubblica un file di esempio di ciò che stai facendo.
 

Xfood

Expert
Licensed User
Quale modello di stampante?
È configurato per i comandi ZPL o CPL?

Pubblica un file di esempio di ciò che stai facendo.
Grazie, la stampante e' zebra GK420T, ancora non riesco a collegarla / vederla , domani che sono in ufficio incollo qui il codice che sto provando.
 

TILogistic

Expert
Licensed User
Longtime User
Grazie, la stampante e' zebra GK420T, ancora non riesco a collegarla / vederla , domani che sono in ufficio incollo qui il codice che sto provando.
:D:D
Ho la stessa stampante qui.

il GK420T proviene dalla serie TLP2844 ,GC420
 

Xfood

Expert
Licensed User
Quindi se fai delle prove mi potresti mandare un progettino di esempio, cosi evito di disperarmi, 2 bottoni, 1 che la collega in usb senza driver, e invia alla stampante un,'etichetta qualsiasi in zpl, 1 un bottone che utilizza i driver di windows della stampante configurata.

Te ne sarei veramente grato, e se fai un salto in sicilia, ci prendiamo una bella Granita😁😁
 

TILogistic

Expert
Licensed User
Longtime User
Carica un esempio di ciò che hai fatto.
E ti faccio pagare l'invito, visto che ho un viaggio in Europa previsto per giugno 2022, se la pandemia di COVID lo consente.

😊😊😊😊
 

Lello1964

Well-Known Member
Licensed User
Longtime User
Quindi se fai delle prove mi potresti mandare un progettino di esempio, cosi evito di disperarmi, 2 bottoni, 1 che la collega in usb senza driver, e invia alla stampante un,'etichetta qualsiasi in zpl, 1 un bottone che utilizza i driver di windows della stampante configurata.

Te ne sarei veramente grato, e se fai un salto in sicilia, ci prendiamo una bella Granita😁😁
vengo pure io in Sicilia.

Appena ci liberano.
 

giannimaione

Well-Known Member
Licensed User
Longtime User
Mi piacerebbe provare le due soluzioni, in ogni caso ho collegato la stampante in usb, installato driver, e tramite zebra label riesco a stampare.
Vorrei stampare da b4j creando un'etichetta con i comandi ZPL.
quindi stampante installata, configurata e funzionante in pc win?
con b4j e con diverse stampanti barcode con i rispettivi linguaggi, io utilizzo questo codice:
inizializza la classe, passando il "NOME DELLA STAMPANTE" come da configurazione windows
B4X:
Sub Class_Globals
    'Private fx As JFX
    Private printString As String
    Private feed As String
    Private printerGen As String
    Public Constant As Int = 32
End Sub
' "" = Mostrar lista
Public Sub Initialize(printer As String)
    printerGen = printer
End Sub
'
public Sub addString(str As String)
    If str.Length > Constant Then
        str = str.SubString2(0,Constant + 1)
    End If
    feed = feed & str & Chr(10)
End Sub
'
public Sub centerText(str As String)
    If str.Length > Constant Then
        addString(str.SubString2(0,Constant + 1))
    End If
    Dim half As Int = (Constant - str.Length) / 2
    For i = 1 To half
        str = " "&str
    Next
    addString(str)
End Sub
'
Public Sub addnewline
    feed = Chr(34) & "RISO SCOTTI" & Chr(34) & "585H1R" & Chr(10)
    feed = feed & "1T"
End Sub

public Sub addnewLine2
    feed = "{D1370,0817,1350|}"
    feed = feed & Chr(10) & "{C|}"
    feed = feed & Chr(10) & "{PV00;0160,0120,0062,0063,B,00,B=Tex Prime srl|}"
    feed = feed & Chr(10) & "{PV01;0050,0250,0041,0042,B,00,B=Felpa Boucle Trifoglio|}"
    feed = feed & Chr(10) & "{PV02;0050,0370,0041,0042,B,00,B=Bagno: Jeans|}"
    feed = feed & Chr(10) & "{PV03;0050,0470,0041,0042,B,00,B=Colore: Azzurro|}"
    feed = feed & Chr(10) & "{PV04;0050,0580,0041,0042,B,00,B=Peso Netto: 24,58 Kg|}"
    feed = feed & Chr(10) & "{PV05;0050,0699,0041,0042,B,00,B=Metri: 375|}"
    feed = feed & Chr(10) & "{XB00;0110,0810,A,3,03,0,0128,+0000000000,000,0,00=>51111222333245837>65|}"
    feed = feed & Chr(10) & "{PV06;0193,0973,0034,0035,B,00,B=11112223332458375|}"
    feed = feed & Chr(10) & "{XS;I,0001,0000C5000|}"
End Sub
'
public Sub print (stringa As String)
    printString = Chr(10) & Chr(10) & Chr(10)
    printString = ""
    printString = printString & stringa 'feed
    jo.RunMethod("printString", Array(printerGen, printString))
    'Dim by() As Byte = jo.RunMethodjo("cut",Null)
    'jo.RunMethod("printBytes",Array(printerGen,by))
End Sub
'
private Sub jo As JavaObject
    Return Me
End Sub
'CP1252 , UTF-8, CP437
#If java

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.util.ArrayList;
import java.util.List;
 
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.MediaPrintableArea;
 
    public void printString(String printerName, String text) {
        try {
        // find the printService of name printerName
        DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
        PrintService printService[] = PrintServiceLookup.lookupPrintServices(
                flavor, pras);
        PrintService service = findPrintService(printerName, printService);
 
        DocPrintJob job = service.createPrintJob();
      
            byte[] bytes;
 
            // important for umlaut chars
            bytes = text.getBytes("UTF-8");
 
            Doc doc = new SimpleDoc(bytes, flavor, null);
 
          
            job.print(doc, null);
 
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
 
    }
 
    public void printBytes(String printerName, byte[] bytes) {
      
        DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
 
        PrintService printService[] = PrintServiceLookup.lookupPrintServices(
                flavor, pras);
        PrintService service = findPrintService(printerName, printService);
 
        DocPrintJob job = service.createPrintJob();
 
        try {
 
            Doc doc = new SimpleDoc(bytes, flavor, null);
 
            job.print(doc, null);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
  
    private PrintService findPrintService(String printerName,
            PrintService[] services) {
        for (PrintService service : services) {
            if (service.getName().equalsIgnoreCase(printerName)) {
                return service;
            }
        }
 
        return null;
    }

    public byte[] cut() {
        byte[] cutP = new byte[] { 0x1d, 'V', 1 };
        return cutP;
    }
#end if


'    Public int print(Graphics g, PageFormat pf, int page)
'            throws PrinterException {
'        If (page > 0) { /* We have only one page, And 'page' is zero-based */
'            Return NO_SUCH_PAGE;
'        }
'
'        /*
'         * User (0,0) Is typically outside the imageable area, so we must
'         * translate by the X And Y values in the PageFormat To avoid clipping
'         */
'        Graphics2D g2d = (Graphics2D) g;
'        g2d.translate(pf.getImageableX(), pf.getImageableY());
'        /* Now we perform our rendering */
'
'        g.setFont(new Font("Roman", 0, 8));
'        g.drawString("Hello world !", 0, 10);
'
'        Return PAGE_EXISTS;
'    }
 

Xfood

Expert
Licensed User
quindi stampante installata, configurata e funzionante in pc win?
con b4j e con diverse stampanti barcode con i rispettivi linguaggi, io utilizzo questo codice:
inizializza la classe, passando il "NOME DELLA STAMPANTE" come da configurazione windows
B4X:
Sub Class_Globals
    'Private fx As JFX
    Private printString As String
    Private feed As String
    Private printerGen As String
    Public Constant As Int = 32
End Sub
' "" = Mostrar lista
Public Sub Initialize(printer As String)
    printerGen = printer
End Sub
'
public Sub addString(str As String)
    If str.Length > Constant Then
        str = str.SubString2(0,Constant + 1)
    End If
    feed = feed & str & Chr(10)
End Sub
'
public Sub centerText(str As String)
    If str.Length > Constant Then
        addString(str.SubString2(0,Constant + 1))
    End If
    Dim half As Int = (Constant - str.Length) / 2
    For i = 1 To half
        str = " "&str
    Next
    addString(str)
End Sub
'
Public Sub addnewline
    feed = Chr(34) & "RISO SCOTTI" & Chr(34) & "585H1R" & Chr(10)
    feed = feed & "1T"
End Sub

public Sub addnewLine2
    feed = "{D1370,0817,1350|}"
    feed = feed & Chr(10) & "{C|}"
    feed = feed & Chr(10) & "{PV00;0160,0120,0062,0063,B,00,B=Tex Prime srl|}"
    feed = feed & Chr(10) & "{PV01;0050,0250,0041,0042,B,00,B=Felpa Boucle Trifoglio|}"
    feed = feed & Chr(10) & "{PV02;0050,0370,0041,0042,B,00,B=Bagno: Jeans|}"
    feed = feed & Chr(10) & "{PV03;0050,0470,0041,0042,B,00,B=Colore: Azzurro|}"
    feed = feed & Chr(10) & "{PV04;0050,0580,0041,0042,B,00,B=Peso Netto: 24,58 Kg|}"
    feed = feed & Chr(10) & "{PV05;0050,0699,0041,0042,B,00,B=Metri: 375|}"
    feed = feed & Chr(10) & "{XB00;0110,0810,A,3,03,0,0128,+0000000000,000,0,00=>51111222333245837>65|}"
    feed = feed & Chr(10) & "{PV06;0193,0973,0034,0035,B,00,B=11112223332458375|}"
    feed = feed & Chr(10) & "{XS;I,0001,0000C5000|}"
End Sub
'
public Sub print (stringa As String)
    printString = Chr(10) & Chr(10) & Chr(10)
    printString = ""
    printString = printString & stringa 'feed
    jo.RunMethod("printString", Array(printerGen, printString))
    'Dim by() As Byte = jo.RunMethodjo("cut",Null)
    'jo.RunMethod("printBytes",Array(printerGen,by))
End Sub
'
private Sub jo As JavaObject
    Return Me
End Sub
'CP1252 , UTF-8, CP437
#If java

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.util.ArrayList;
import java.util.List;
 
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.MediaPrintableArea;
 
    public void printString(String printerName, String text) {
        try {
        // find the printService of name printerName
        DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
        PrintService printService[] = PrintServiceLookup.lookupPrintServices(
                flavor, pras);
        PrintService service = findPrintService(printerName, printService);
 
        DocPrintJob job = service.createPrintJob();
     
            byte[] bytes;
 
            // important for umlaut chars
            bytes = text.getBytes("UTF-8");
 
            Doc doc = new SimpleDoc(bytes, flavor, null);
 
         
            job.print(doc, null);
 
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
 
    }
 
    public void printBytes(String printerName, byte[] bytes) {
     
        DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
 
        PrintService printService[] = PrintServiceLookup.lookupPrintServices(
                flavor, pras);
        PrintService service = findPrintService(printerName, printService);
 
        DocPrintJob job = service.createPrintJob();
 
        try {
 
            Doc doc = new SimpleDoc(bytes, flavor, null);
 
            job.print(doc, null);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private PrintService findPrintService(String printerName,
            PrintService[] services) {
        for (PrintService service : services) {
            if (service.getName().equalsIgnoreCase(printerName)) {
                return service;
            }
        }
 
        return null;
    }

    public byte[] cut() {
        byte[] cutP = new byte[] { 0x1d, 'V', 1 };
        return cutP;
    }
#end if


'    Public int print(Graphics g, PageFormat pf, int page)
'            throws PrinterException {
'        If (page > 0) { /* We have only one page, And 'page' is zero-based */
'            Return NO_SUCH_PAGE;
'        }
'
'        /*
'         * User (0,0) Is typically outside the imageable area, so we must
'         * translate by the X And Y values in the PageFormat To avoid clipping
'         */
'        Graphics2D g2d = (Graphics2D) g;
'        g2d.translate(pf.getImageableX(), pf.getImageableY());
'        /* Now we perform our rendering */
'
'        g.setFont(new Font("Roman", 0, 8));
'        g.drawString("Hello world !", 0, 10);
'
'        Return PAGE_EXISTS;
'    }
grazie @giannimaione questo codice l'ho trovato qui sul forum,
ma non riesco a capire come mandare i dati alla stampante 1 Zebra , collegata in usb , invece della stampante sempre collegata Laser A4?
 

TILogistic

Expert
Licensed User
Longtime User
se vuoi stampare su tutte le stampanti Zebra con linguaggio ZPL o CPL.
Guarda e abbassa il DSK.


L'API è ZSDK_API.jar

C'è una demo e un codice di connessione TCP, USB, etc.

Provalo
C:\Program Files\Zebra Technologies\link_os_sdk\PC\v2.14.5198\demos\release

1645219577797.png
 

TILogistic

Expert
Licensed User
Longtime User
Voglio che tu veda le opzioni di connessione e provi la tua stampante.

e poi ti dirò come usare l'API in B4J per Windows
 

Xfood

Expert
Licensed User
ok grazie, ho la stampante in ufficio, adesso ho appena installato l'api sdk suggerito da te suggerito
domani provo, grazie mille....
1645220464497.png
 
Top