I have a question related to this topic: New line in Zebra ZPL. I want to print a serial number, which is longer than the label. There shouldn't be a hyphen in this seral number.
It is printed by a PLC, which gets the format as ZPL from a PC. I get the ZPL file only, if the format changes. The data which have to be printed on the label will be given as variables.
I can't change the communication configuration (e.g. connect the printer directly to the PLC or change the program in the PC). This means, I can't split the serial number into two lines (like I did in another project). But, of course, I can change the PLC program, but it must be changeable to new formats without changing the PLC program again. So from my point of view, splitting the code in the PLC program is not an option.
Until now, I only had to possibility to change the code, to have automatic word wrap with a hyphen or split the serial number into two lines.
Hopefully someone has a suggestion.
With kind regards,
Alexander Härtel
Use the ^FB command (field box).
The first argument is the width in dots (always in dots, this is the only command that ignores ^CU units of measurement (which is an undocumented fact)), the second argument is the maximum number of lines the box can have. (There are other arguments too.)
^FO100,350
^FB100,2
^FD1234567890^FS
Labelary example.
Related
I have a file located at C:\printme.txt
I want to print it to my printer which is named POS80
Is there not a simple command for windows in the command prompt to say Print C:\printme.txt to POS80?
It should be noted that POS80 is also the default printer so a command that does not include the printer name but just sends to the default printer would be acceptable too.
Your mileage can vary using the legacy command Print
It MAY work if you have a line printer set to LPT1 and worth trying
Print C:\printme.txt "POS80" However I expect you are getting the error message "Unable to initialize device PRN" that is not unusual as PRN was traditionally LPT1.
Later you say its USB connected. which means its serial (old Com ports) whereas Line Printer (old LPT ports) were parallel hence the potential needs for fettling, but in windows you can use the port name for the printer and that resolves ports issue (files can become ports or vice versa) thus no real problem.
Now you could try messing with printer port redirections to get around that but it would likely mess up other application printing. Thus by far the simplest is make the printer the default one which is what you have.
To avoid the Save Output File As dialog when adding a print job to the default queue, ensure that your default printer isn't Microsoft XPS Document Writer, Microsoft Print to PDF, or other print-to-file options.
So what is Windows 10 doing when you right click print? Generally it fires up the associated FTA (File Type Application) which for .txt (or similar chosen) is NotePad.
Thus the simplest way to command line print plain text is
NotePad /pt C:\printme.txt "POS80"
NotePad settings can be changed in the registry before and after you print, via the command line, even skewing letters (fun to prank colleagues if you use 1 degree off kilter), however you cannot set line spacing or add graphics, for those you need to step up to WordPad which will accept docx, rtf, odt and most simple text file types.
Several other file types can also be printed in a similar way such as graphics images, using mspaint.
Later you say you are sending html as text and want graphic output not textual.
So the x problem is the files are not plain.txt they are plain.htm so need translation from html by graphic conversion (rendering) to pass through a printer language converter (printer driver) That's a totally different question but the answer is still much the same.
Traditionally you would simply use
rundll32.exe mshtml.dll,PrintHTML "C:\printme.txt"
But security exploits have made that simplicity more of a challenge thus
best to run it like this.
cd /D C:\Windows\System32 & rundll32.exe mshtml.dll,PrintHTML "C:\printme.txt"
And Microsoft Current Policy is "User confirmation is needed to print an HTML page through MSHTML.DLL." thus you need to hit print using sendkeys.
If your preference is FireFox rendering, from the command line you needed to install an extension, however with tightened security in windows 10, I dont know if that's still possible.
If you wish to print xml or html graphically in windows 10+ you can ask Edge --headless to print those for you to PDF, either as screen shot or rendered text, silently without enforced html confirmation ! And again you can print html automatically by using sendkeys to replace the user.
However printing PDF from the command line is where the real fun begins.
It is possible if the PDF is the correct type prepared for the printer (even a simple thermal or inkjet) then an old school copy /b file.pdf "printer" may work but dont send a big file to test, just a tiny Hello World!, or your carbon neutrality is instantly wiped out by reams of paper with one or two letters each.
My dirt cheap HP accepts files that can be viewed as PDF that start textually like this i.e. which have the PCLm 1 comment.
%PDF-1.7
%PCLm 1.0%
223 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/XObject <<
/Image0 3 0 R
/Image1 4 0 R
For most POS printers a PDF either needs to be processed in middleware or usually top end firmware such as onboard Direct PDF
Thus we come back to using html bitmap and text directives that will either need a print driver or be programmed to a port or file for later copy /b to device.
As you no doubt know Microsoft have not made it simple to print file.html default in fact the opposite resulting in many third part apps for win xp-win 11 such as https://www.bersoft.com/htmlprint/index.htm#overview amongst many other options.
Currently it will show N/A as number of pages in the windows spool queue, is this possible to show the number of pages and what page is printing with bi-directional support on? with this file format? surely the printer itself must know what page is printing/how many pages have printed. thanks.
I can only answer the PostScript part of this question, not the Windows spool queue. I don't know how you are inserting the PostScript into the spool queue, but assuming you are printing from an application then my very hazy memory suggests that it's the application which declares the number of pages in the job.
The printer doesn't know how many pages a PostScript program contains. In fact, in the most general case, it's not possible to determine how many times a PostScript program will execute the showpage operator. That's because PostScript is a programming language and the program might execute differently on different interpreters, or under different conditions. It might print an extra page on Tuesdays for example.
Or to take an admittedly silly example:
%!
0 1 rand {
showpage
} for
That should print a random number of empty pages.
There are conventions which can indicate how many pages a PostScript program is expected to execute, the Document Structuring Convention contains comments which tell a PostScript processor (not a PostScript interpreter, which ignores comments, a processor treats the PostScript as just data and doesn't execute it) how many pages it has, amongst other data such as the requested media size, fonts, etc.
Not all PostScript programs contain this information and it can sometimes be awkward to extract (the 'atend' value is particularly annoying forcing the processor to read to the end of the file to find the value). Additionally people have been know to treat PostScript programs like Lego bricks and just concatenate them together, which makes the comments at the start untrustworthy. This is especially true if the first program has %% Pages: (atend)
Most printers do execute a job server loop, which means that it is possible for them to track which page they are executing, even if they don't know how many pages there will be.
It's also certainly true that a PostScript program running on a printer with a bi-directional interface could send information back to the print spooler, but there's no guarantee that a printer has a bi-directional communication interface, and there's no standard that I know of for the printer to follow when sending such information back to the computer. What should it send ? Will it be the same for Windows as Mac ?
My program constantly outputs text to the terminal. I need the user input line to always stay below this output; if the user types something, it shouldn't jump over the output.
Is there any Ruby library that can provide this functionality?
There could not be any ruby library providing this functionality since none of the known terminals support splitting the areas inside themselves.
This is the terminal issue: they are not capable of dividing their internal window into two parts.
What you can do, though, it to use two different shells for input and for output with IO#popen.
I have a small problem in my code. I have programmed my program to find word inside a .txt file and now I want to know how to make SAPI speaking from 5000 characters from the place the word is found inside the .txt file.
If you have the position of the word in the file it shouldn't be a challenge to read the next 5000 characters into a buffer that can then be fed to the speech engine. It's possible that a hard 5000 character cutoff will leave a word broken at the end so you may want to seek ahead past that point to the next blank space or whatever to make the end smoother.
Without knowing specifics like language and platform and which SAPI you are using it is impossible to give more detailed advice.
I am working on reading the barcode using a scanner and I have the following questions:
Is there a way to distinguish between the input from the keyboard and input from the scanner ? This is required for me because the barcode reader will include a preamble, terminator and a prefix to the barcode value. For ex, if the value is 12345 the barcode will have \pre12345\ where \ and \ indicate the start and end and pre identifies the type of data.
If I know that the data is being typed from keyboard and not from a scanner then I would show whatever the user types.
If I know that the data is from a scanner then I will strip of the \pre and \ and show only the data.
Thanks,
My answer assumes that you are using a barcode scanner in "keyboard wedge" mode where it simply emulates a keyboard and does not have some special connection. These devices are often USB and work this way out of the box without any further configuration.
Would the user ever have occasion to actually type your \pre text? Often the prefix is chosen specifically to be a set of characters that the user will never enter or will at least very rarely want to enter. Thus, the mere presence of the prefix indicates a scanned barcode.
Another option would be to time the input. For example, the input from the barcode scanner will probably all be complete within a very short time (e.g. 50ms). If a user were typing the value via the keyboard, it would be impossible for him/her to type the prefix, the data and the postfix all within 50ms. (Of course, assumption here is that input will be made by an actual human and not by automated tools)
well yes! input from the barcode scanner should have first initialized itself through a COM port or serial connection. I know that many apps restrict input to certain field through specific ports, but beyond that I'm not sure.
One solution that I came up with was to start all of our barcodes with a unique sequence of characters not known to the user. I check for this sequence on the input to tell me how the data was entered.