Author Topic: Printing to a Zebra Printer from AdvancedHMI  (Read 18508 times)

Godra

  • Hero Member
  • *****
  • Posts: 1457
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #15 on: August 12, 2019, 10:10:35 PM »
Sprungmonkey,

Try the attached solution in VS 2013.
Make sure to install Net Framework 4.7.1 Developer Pack first (if you don't have it already installed).

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #16 on: August 15, 2019, 09:31:39 AM »
Sprungmonkey,

Try the attached solution in VS 2013.
Make sure to install Net Framework 4.7.1 Developer Pack first (if you don't have it already installed).

Thanks Godra! I will give a try as soon as I can.

bachphi

  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #17 on: January 05, 2020, 01:08:09 PM »
an improved version of Search & Replace:
UCL =================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
My understanding of computer is well below six Σ.
Unless what I am saying is logically defined in a PLC, everything else might be beyond my control.
LCL =================

bachphi

  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #18 on: February 20, 2020, 06:09:59 PM »
Another improved Search & Replace version (? may be not),
But it does give the flexibility of using different string size.




Code: [Select]
/********************************************************************
• .NET equivalent of STRING.REPLACE
• Search a string for a specified string and replace it
• Added looping capability to replace more than one
• Added passing different custom source string size
********************************************************************/

//Determine the size of the passed in array
SIZE(SourceArray,0,array_size);

FOR index:= 0 TO array_size-1 DO
COP(SourceArray[index],sSource.DATA[index],1);
END_FOR;
//
sSource.LEN:= array_size;

WHILE sSource.LEN > sSearch.LEN DO
FIND(sSource,sSearch,1,PosFound);
IF PosFound > 0 then
DELETE(sSource,sSearch.LEN,PosFound,sSource);
INSERT(sSource,sReplace,PosFound,sSource);
ELSE
EXIT;
END_IF;
END_WHILE;

FOR index:= 0 TO sSource.LEN-1 DO
COP(sSource.DATA[index],SourceArray[index],1);
END_FOR;

UCL =================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
My understanding of computer is well below six Σ.
Unless what I am saying is logically defined in a PLC, everything else might be beyond my control.
LCL =================

PLCHorse

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #19 on: February 22, 2025, 07:22:02 PM »
I tried this but I'm getting an error in RawPrinterHelper... any ideas?



Attached are some code bits from a project I did to print to a Zebra printer. I used Zebra Designer software to create a label, then exported it to a "prn" file. Within the label, I specified variable fields by closing them in brackets. The code would look for those fields and substitute it with the data.

The code does use native methods so it will only work on Windows. It sends information to the printer that has been installed using the Zebra printer driver.

PLCHorse

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #20 on: February 22, 2025, 08:07:25 PM »
Changing from OpenPrinterW DLL call to OpenPrinter2W call seems to have worked... I do not understand what i'm doing here. but i printed something!

I tried this but I'm getting an error in RawPrinterHelper... any ideas?



Attached are some code bits from a project I did to print to a Zebra printer. I used Zebra Designer software to create a label, then exported it to a "prn" file. Within the label, I specified variable fields by closing them in brackets. The code would look for those fields and substitute it with the data.

The code does use native methods so it will only work on Windows. It sends information to the printer that has been installed using the Zebra printer driver.

PLCHorse

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Printing to a Zebra Printer from AdvancedHMI
« Reply #21 on: March 12, 2025, 04:16:17 PM »
NATIVE METHODS > OPENPRINTER>
ByVal pd as Long »»»» ByVal pd as IntPtr

Then, can use OpenPrinterW instead of OpenPrinter2w

Had to be an int p'tr.

Changing from OpenPrinterW DLL call to OpenPrinter2W call seems to have worked... I do not understand what i'm doing here. but i printed something!

I tried this but I'm getting an error in RawPrinterHelper... any ideas?



Attached are some code bits from a project I did to print to a Zebra printer. I used Zebra Designer software to create a label, then exported it to a "prn" file. Within the label, I specified variable fields by closing them in brackets. The code would look for those fields and substitute it with the data.

The code does use native methods so it will only work on Windows. It sends information to the printer that has been installed using the Zebra printer driver.