Warm tip: This article is reproduced from serverfault.com, please click

Edit .prn file for printing it in C#

发布于 2019-12-09 14:36:26

I downloaded ZebraDesigner 3 to create a custom label with a text field where I wrote "Hello World".

Then I wanted to get its source code by "print to file", but when I open it with any editor I can't find what I wrote previously (Hello World).

What I wanted to do is creating a label with some text fields that are variable because they will get values from my C# application.

This is what I get from .prn file (file created by printing to file function)

^XA
^MMT
^PW639
^LL0320
^LS0
^FO192,128^GFA,01792,01792,00028,:Z64:
eJzt0jFOAzEQBdCxXLjzXsBarjEFYq/kdBRRAhfIebYcxAE4ArMXQKZzgdaMhygOiSKElAKkHRe70iu88/8CLPMfhuUARnmLJhmSJ4L/laFJ9uGS2fHqFuzo4NQ6wtgRBBccbMwLul2zIWEckpopj69489ZsmzFus5otTzMO895K4XyLMa/By7jnKeH9phkHjBy+DCbG2B9sIo8r7tU6eCdM/eE+NfJqHlaE3HaYyqwmnxKuZgQ/mkQ9nhmD7lDtdAdmr7tXk92p7S62z8xmkyUzwvXdUdYfmrX8SkmyppZ17ShrR9WkI/rWUcfabTXpllq3yyzzV+cTr8C3dA==:ED50
^PQ1,0,1,Y^XZ

How can I change those text field from C#?

Questioner
Alessio Raddi
Viewed
0
GSerg 2019-12-09 23:54:27

The "Print to file" feature sends the label image to the Zebra driver, which converts it to a picture, encodes and ZIP-compresses it, and produces a ZPL file where the only payload is that single picture (and several supplementary commands to set label dimensions and print quantity). You can't blame the driver, it would be pretty hard to convert random document from a random Windows application to a meaningful series of fields with data.

The payload command in your file is

^GFA,01792,01792,00028,:Z64:
eJzt0jFOAzEQBdCxXLjzXsBarjEFYq/kdBRRAhfIebYcxAE4ArMXQKZzgdaMhygOiSKElAKkHRe70iu88/8CLPMfhuUARnmLJhmSJ4L/laFJ9uGS2fHqFuzo4NQ6wtgRBBccbMwLul2zIWEckpopj69489ZsmzFus5otTzMO895K4XyLMa/By7jnKeH9phkHjBy+DCbG2B9sIo8r7tU6eCdM/eE+NfJqHlaE3HaYyqwmnxKuZgQ/mkQ9nhmD7lDtdAdmr7tXk92p7S62z8xmkyUzwvXdUdYfmrX8SkmyppZ17ShrR9WkI/rWUcfabTXpllq3yyzzV+cTr8C3dA==:ED50

, which unzips to

enter image description here

There is not much to edit there.

In order to manually achieve the same, you would write:

^XA
^MUm
^FO10,10^A0,10^FDHello World^FS
^MUd
^XZ