Answered Generating a QR Barcode

Just to add more work to your plate. As an alternative you could use phantom.js and and a bit of javascript you can generate a QR code to file in an assortment of image file types. This is a cross OS platform if you are interesting using on Linux as well-as Windows.
Hi there!

How do you call this from within OE? Do you call a web service? Any chance of showing some sample code of how to implement it?
 
So I sat down for about 10 mins about how to actually do this using phanon.js and I realize it might be even easier to create QR code using node.js from the command line. I wrote a very very simple javascript code witch uses qr-image npm package ( library's for for node.js)

In my testing I was using Windows but node.js is cross OS complaint.

So you will need to download and install node.js: Download | Node.js
Install the QR-image package:
npm install qr-image

This is my quick and dirty javascript code. "Use it at your own discretion. Blar Blar Blar".
This is like a wrapper for the qr-image package and producint the qrcode image to disk.

qr-generator.js
Code:
var qr = require('qr-image');
var fs = require('fs');

//Test for the number of pass parameters.
if (process.argv.length <= 3) {
    console.log("Usage: " + __filename + " QRCODE filepath");
    process.exit(-1);
}

// Get the first and second prameters.
// Actually node.js see the executalble and the node.js script as the first and second parameters.
var qrCodeData = process.argv[2];
var imageFile  = process.argv[3];

// generate the QR code Image
var code = qr.image(qrCodeData , { type: 'png' });

//Writes the binary image to disk
code.pipe(require('fs').createWriteStream( imageFile ));

process.exit(0);

from OpenEdge you would simply use the OS-COMMAND statement:

Code:
oscomline = substitute('node qr-generator.js &1 &2,
                                                     QUOTE('SOME DATA'),
                                                     "qrimage.png").

OS-COMMAND value(oscomline).

Ref:
GitHub - alexeyten/qr-image: Yet another QR code generator
qr-image
 
In fact I would even challenge my self to write a pure QR code generator in OpenEdge and have it produce a PNG file. However to the limitation on bitwise logic shifting and other stuff it just too difficult to code.
 
cool stuff!

if i get some free time, i'll add the docxfactory barcode generator to the progress standard libraries project. the code is already there and working so it shouldn't be a big job.

so it'll actually be a c/c++ library with a progress 4gl wrapper but it will be cross platform.

docxfactory supports a pretty extensive list of 1d and 2d barcodes.
 
The error message is usually due to a .NET component being referenced missing from the assemblies file. As a quick test try the following:
  1. Place the ThoughtWorks.QRCode.dll file in the Progress/Project working directory - MESSAGE SESSION:TEMP-DIRECTORY VIEW-AS ALERT-BOX.
  2. As per this site - OpenEdge 11.7 Documentation - add the ThoughtWorks.QRCode.dll file via the "Local Assemblies" tab.
  3. Save the assemblies.xml in the same directory as the ThoughtWorks.QRCode.dll file and quit Assembly References. You may need to restart the session so these will be picked up.
  4. Try writing a line of code such as DEFINE VARIABLE oEncoder AS ThoughtWorks.QRCode.Codec.QRCodeEncoder NO-UNDO. and then checking syntax. If you get this error it means Progress is not referencing the components:
Invalid datatype specified: ThoughtWorks.QRCode.Codec.QRCodeEncoder. Specify a datatype such as 'character' or the name of a class. (5638)
** Could not understand line 1. (196)

This should hopefully get you started.
 
What happens when you run something similar to this - replace C:\DirectoryofDLL with the directory ThoughtWorks.QRCode.dll is stored in:
Code:
DEFINE VARIABLE oAssembly AS System.Reflection.Assembly NO-UNDO.

oAssembly = System.Reflection.Assembly:LoadFile("C:\DirectoryofDLL\ThoughtWorks.QRCode.dll").

MESSAGE VALID-OBJECT(oAssembly) VIEW-AS ALERT-BOX.
 
I don't execute the code.
I using the 11.6 version.

View attachment 2041
FIRST place no .pf file in this statement

-assemblies C:\DirectoryofDLL

1603376929212.png




USING ThoughtWorks.QRCode.Codec.*.
USING System.Drawing.*.

DEF VAR i-ix AS INT.
DEF VAR c-local AS CHAR.
DEF VAR c-arquivo AS CHAR.
DEF VAR c-texto AS CHAR.

DEFINE VARIABLE c-QrCode AS ThoughtWorks.QRCode.Codec.QRCodeEncoder NO-UNDO.
DEFINE VARIABLE c-imagem AS System.Drawing.Image NO-UNDO.


REPEAT i-ix = 1 TO (NUM-ENTRIES(FILE-INFO:FILE-NAME,'\') - 1):
ASSIGN c-local = c-local + '\' + ENTRY(i-ix, FILE-INFO:FILE-NAME,'\').
END.

ASSIGN c-local = SUBSTRING(c-local,2,5000)
c-arquivo = "Qrcode.png"
c-local = c-local + "\" + c-arquivo
c-texto = "A:123456789*B:999999990*C:PT*D:FT*E:N*F:20191231*G:FT AB2019/0035*H:CSDF7T5H-0035*I1:PT*I2:12000.00*I3:15000.00*I4:900.00*I5:50000.00*I6:6500.00*I7:80000.00*I8:18400.00*J1:PT-AC*J2:10000.00*J3:25000.56*J4:1000.02*J5:75000.00*J6:6750.00*J7:100000.00*J8:18000.00*K1:PT-MA*K2:5000.00*K3:12500.00*K4:625.00*K5:25000.00*K6:3000.00*K7:40000.00*K8:8800.00*L:100.00*M:25.00*N:64000.02*O:513600.58*P:100.00*Q:kLp0*R:9999*S:TB;PT00000000000000000000000;513500.58".

c-QrCode = NEW QRCodeEncoder().
c-QrCode:QRCodeVersion = 18.
c-imagem = c-QrCode:Encode(c-texto).

DELETE OBJECT c-QrCode.
c-imagem:Save(c-local,System.Drawing.Imaging.ImageFormat:png).


OS-COMMAND SILENT VALUE(c-local).
 

Attachments

Just fyi and as I see this thread coming up, if you need to generate a QR Code into a pdf file, pdfInclude is now able to generate a lot of 1D and 2D barcodes (including QR Code, but also datamatrix and PDF417) and put them into your pdf files.
All done in 4GL/ABL, no external dependency needed.
 
Back
Top