Hi All,
XML Data to be put in PDF417 datakey in the Reporting module -
<Component>
<companyCode>{companyCode}</companyCode>
<idNumber>{idNumber}</idNumber>
<C203>{C203}</C203>
<C204>{DateAndTime}</C204>
<C205>{C205}</C205>
<C206>{C206}</C206>
<C207>{C207}</C207>
<C208>{C208}</C208>
<C209>{C209}</C209>
<C210>{C210}</C210>
<C211>{C211}</C211>
<C213>{C213}{C213}</C213>
<C214>{C214}{C214}</C214>
<C215>{C215}{C215}</C215>
<C216>{C216}{C216}</C216>
<C217>{C217}{C217}</C217>
<C218>{C218}{C218}</C218>
</Component>
The resulting PDF417 however results as the following -
I am not able to scan the barcode no matter how much i adjust the scaling and dimensions. If i fit the PDF code within the label, i am not able to scan it and vice versa.
I'm also trying to fit this code into a 4in X 4in label.
I have no option but to use the data in XML form even though other dataset formats might work.
Property Inspector - for the above result
Am i missing something here? How do i configure the settings further?
Thanks!
I can have a look although you might have to educate me. Where does the XML get added to the Data Sources?
XML comes from a Perspective screen which gets data from the DB
Sure, but is it passed in as a parameter to the report, and if so, what sort of Datakey is it? I can see <component> in your Properties | Barcode | Datakey, but I've never seen a datakey with < ...> brackets.
Based on the renders, it is missing either the starting bars or ending bars. That is, the code is overflowing the available space. You indicate that it also doesn't scan if scaled, then it must be hitting the minimum for the pixel sizes. You simply may not be able to fit it on the small label.
I'm passing the xml code as a string...how do i decrease the number of columns in the PDF code?
is there any way to create and send an image of the barcode to reports through scripting?
As Phil says, you're missing the bars at one end of the code. You seem to have the stop pattern, but the start pattern has been cropped.
Figure 1. Image source: https://en.wikipedia.org/wiki/PDF417.
I was able to get it to work by setting the X and Y scale to 0.25.
Figure 2. PDF417 on 4" x 4" report page. The low density is due to the short 'default' message.
Figure 3. The preview result with the required XML data.
To generate the barcode from the input parameters:
Figure 4. Writing the generated XML out to an "input" parameter.
updateData script code
companyCode = data['companyCode']
idNumber = data['idNumber']
xml = """<Component>
<companyCode>%s</companyCode>
<idNumber>%d</idNumber>
<C203>{C203}</C203>
<C204>{DateAndTime}</C204>
<C205>{C205}</C205>
<C206>{C206}</C206>
<C207>{C207}</C207>
<C208>{C208}</C208>
<C209>{C209}</C209>
<C210>{C210}</C210>
<C211>{C211}</C211>
<C213>{C213}{C213}</C213>
<C214>{C214}{C214}</C214>
<C215>{C215}{C215}</C215>
<C216>{C216}{C216}</C216>
<C217>{C217}{C217}</C217>
<C218>{C218}{C218}</C218>
</Component>""" % (companyCode, idNumber)
data['pdfXml'] = xml
Good practice would require you to put this code in the Scripting Project Library and call it with the first two parameters.
Figure 5. Now the barcode component references the parameter datakey (1) created as shown in Figure 4. (Mine is called pdfXml and is a string.) If you've set everything up the parameter will show up with the selector button (2).
@sanjanakrishnamurthy My confusion with your original post was that you were posting the XML in the Datakey field. I didn't think you could do that. I think I was right!
If you can't select the datakey with the selector button (Figure 5) then it won't work because it doesn't exist!
Wow, thanks for such a detailed explanation!
Buuuut
But there's one more caveat. According to our company's standards, we need the barcode component's size to be 2.19in by 1.08in. When we keep the barcode to that size, it doesn't scan with our Honeywell Barcode Scanner...
So now i'm looking into scripting options to create the barcode... If you have any libraries that come to mind for this purpose, please let me know!
So got to know a few things...
- The XML payload that i'm passing to the barcode is too large to be able to fit into the desired barcode size.
- Both scripting (used zxing libraries) (thank god for github copilot, i guess) and manipulation of scales X and Y in reporting had us come to the same conclusion as above.
Any ideas you guys have will help us a lot!
Thanks! 
It may be that you're getting to the point where your printer driver is altering how many pixels per bar inconsistently. e.g. On a 300 dpi printer a 0.05" bar will be 45 pixels wide. Rounding errors on scaling would cause this to vary ±1 pixel or 2.2%. The same job on 100 dpi printer would have three times the error. At some point this becomes a problem for the scanner.
What is the printer make and mode and what is the print resolution?
Figure 6. The image rendered by Ignition.
- The '417' in PDF417 signifies that each pattern in the code consists of 4 bars and spaces in a pattern that is 17 units (modules) long. This includes the white gap after each pattern.
- Your barcode has 21 characters total, so 21 × 17 = 357 vertical 'lines' + 1 extra at the end of the stop pattern. (I deduced the last part by overlaying one of the other characters on the Stop Pattern to check the width.) So 358 lines total. You should get the most consistent results when the pixel width of the barcode is an integer multiple of 358.
- Make sure that you have the required quiet zone at the start and end of the barcode. (This isn't specified in the Wikipedia article.) Judging by your screenshot this isn't your problem.
It should be clear from the last point that trying to print a 2.19" label at, say, 100 dpi, can't work because it can print only 219 of the 358 lines at that resolution.
Suggestions:
- Provide the printer information requested.
- Create a test report on a laser printer with the same barcode printed at various scales and see at what scale the scanner becomes unreliable.
- Remember that if you do try the integer multiple scaling trick that the scaling will be applied to the whole component - not just the barcode. You'll have to measure the actual length of the barcode relative to the length of the component and take that into consideration in your calculations. (Tip: In the barcode properties set
Stroke Style: Border so you can see its outline.)