How to print a pre formatted text in java - java-6

i have string like this
31/12/2002
HINDUSTHAN MOTORS LIMITED
THREE LACS SEVENTY SEVEN THOUSAND THREE HUNDRED
EIGHTY SEVEN ONLY
**377387.00
I want to print it in pre-printed cheque.
how to print this pre-formatted text in java.
I have text file which contains the above pre formatted text
my problem is the extension of the file is different (.kris format)
when I open the file in text doc the formatted text becomes one single line.
So, one single line printing in the printer is not acceptable.
I want to send above text to the printer by using the above fixed format.

1.Download blank cheque template in word format (This is the toughest task I would say if you are searching for free template).
2.Replace labels in it by blank spaces(Make sure that blank spaces occupy same number of spaces as labels).
3.In place of values put some identifiers.for ex: in your case,in place of **377387.00 put **$amount,$date in place of date.
4.Save word as pdf.
5.Now with itext in java replace $ values by your actual values.(itext library in java is used to handle pdfs).
Take print and check if it comes properly on blank cheque else do some minor changes to re-align them.

Related

Is there a 'reserved field identifier' or similar, in ZPL?

I've been doing some work with ZPL recently for printing manufacturing barcode labels etc.
We have several fields on a custom label format that get replaced with real world data, by searching for a specific string of text in the raw ZPL, and then replacing it with the correct application data. E.g. field1 just gets replaced by whatever we actually need to print there, before the TCP packet is constructed and put onto the network to perform the actual print.
This works just fine (so far), but I'm concerned what if some of our field data ever matches the format of a ZPL command for example, what happens.
Page 48 of the huge ZPL specification document shows what we are doing too, where xxxxxxxxxxx is the data to be replaced.
^XA
^FO50,50^ADN,36,20^FDxxxxxxxxxxx
^FS
^XZ
Is there no formal 'reserved field' format/identifier of sorts, or doing what we're doing the only option?
E.g. search and replace field1 in the ZPL below.
^XA
^FO50,50^ADN,36,20^FDfield1
^FS
^XZ
If what you have to replace in the ZPL code is the content of a field (text or barcode), you can try a different approach and use the ^FN command which is used as a placeholder for variable fields and it is usually used to store and recall templates from the printer memory.

Pre-processing multiple text files from a pdf using just pdftotext and sed in a bash script, if possible

I am using the Linux command pdftotext -layout *.pdf to extract text from some pdf files, for data mining. The resultant text files all reside in a single folder, but they need some pre-processing before they can be used.
Issues
Issue 1: The first value of each row in each file that I am trying to access is a barcode, which can be either a 13-digit GTIN code, or a 5-digit PLU code. The problem here is that the GTIN codes are delineated with a single space character, which is hard to replace with a script, as each row also contains a description field which, naturally, also contains single spaces between words. Here I will need to replace a set of 13 numerals plus a space with the same 13 numerals plus two spaces (at least), so that a later stage of the pre-processing can replace all multiple spaces with a tab character.
Issue 2: Another problem I am facing with this pre-processing is the newlines. There are many blank lines between data rows. Some are single blank lines between the data rows, and some are two or more lines. I want to end up with no blank lines between the data rows, but each row will be delineated by a newline character.
Issue 3: The final resulting files each need to be tab separated value files, for importing into a spreadsheet. Some of the descriptions in the data rows may contain commas, so I am using TSV rather than CSV files. I only need a single tab between each value in the row.
Sample rows
(I have replaced spaces with • and newlines with ¶ characters here for clarity.)
9415077026340•Pams•Sour•Cream•&•Chives•Rice•Crackers•100g•••$1.19¶
¶
¶
9415077026296•Pams•BBQ•Chicken•Rice•Crackers•100g•••$1.19¶
¶
61424••••••••••••Yoghurt•Raisins•kg•••$23.90/kg¶
¶
9415077036349•Pams•Sliced•Peaches•In•Juice•410g•••$1.29¶
Intended result
(I have also replaced tabs with ⇥ characters here for clarity.)
9415077026340⇥Pams•Sour•Cream•&•Chives•Rice•Crackers•100g⇥$1.19¶
9415077026296⇥Pams•BBQ•Chicken•Rice•Crackers•100g⇥$1.19¶
61424⇥Yoghurt•Raisins•kg⇥$23.90/kg¶
9415077036349⇥Pams•Sliced•Peaches•In•Juice•410g⇥$1.29¶
What have I tried?
I am slowly learning more about the various Linux script utilities such as sed / grep / awk / tr, etc. There are many solutions posted in StackOverflow which resolve some of the issues that I am facing, but they are disparate and confusing when I attempt to string them all together in the way that I need them. Some are "close, but not quite" solutions, such as replacing all double newlines with a single newline between each data row. I don't need the extra row between them. I have been looking and trying several different options that are close to what I need. It would be helpful if someone could propose a solution which uses a single utility, such as sed, to solve all of the issues at once.

Feeding multiple values into a barcode leaves a '0' barcode. How do I remove this barcode entirely?

I have a system currently set up that creates a barcode for a UPC on a label. This works for single items, but sometimes I have more than one item that tries to feed into that barcode, and when that happens it is set to have no value.
However, instead of there being no barcode, there is actually a small barcode that scans in as 0. How do I ensure that no barcode appears?
^FT350,698^BY2,,75
^BCN,75,N,N,N^FD$ItemBarCode$^FS
"$ItemBarCode$" is an item from a populated table that I do not control, and there can be as many items as needed. The customer requires no barcode when there are multiple items and requires a barcode when there is one. Their sample does not use a typical UPC style barcode.
You say you don't have control over the data in the table, but do you have control over the content/format of $ItemBarCode$?
Have the variable contain the ^FD prefix and ^FS suffix (and remove from the ZPL code). When the variable is blank/empty, nothing will print.
According to the software developer consultant, the solution is to create a customization in the system's code that allows for a logic line to fix this error. This is not something that can be fixed within ZPL itself, rather, there will be two separate labels. For instance,
if single item then print X
if multiple items then print Y
I have same situation. My solution is input barcode command in single line with its data and terminator ^FD and ^FS. So during parsing label file line by line, if data is zero or error than remove entire line. And its work for me

Sublime show lines with specific repeated character

I have a massive (400Mb) CSV file that I need to upload into a database.
The problem is that some lines contain 16 commas (",") and some 17.
I need to find the lines that contain 17 commas so that I can fix them (shouldn't be that many).
Is there a way to search in sublime so that each line becomes visible, that repeatedly contains the same particular character?
This is a job for regular expressions!
Instructions on activating regexes in Sublime Text
You want the regex (.*,){17} - i.e., seventeen instances of any old nonsense followed by a comma.

Whats the right name for fixed position files?

You can structure data in various ways: for example comma separated or tab separated.
But you can also structure data on positions. So, for example, the first 20 characters are meant for a phone number, the following 2 characters are meant for the age of someone etc...
How would you call such a file in general?
If you had id[3]name[5]phone[6]
001Liz 882833
002Paul 892733
003John 927477
this is a fixed format file.

Resources