Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate a qr code on a report.

Filip Brnic

Programmer
Dec 25, 2023
61
RS
Hello, does anyone have experience with QR codes in visual fox pro, if so, how can i generate a QR on the report?
We need this because the people that have our other program requested if we could somehow add the QR code to the receipts, so i was wondering if there is a way to link tables individual records and make it into a QR code (it should be an jpg/bmp or something similar)
Also I'm simply just translating what my programmer told me, and he mentioned that there is a large amount of receipts created at once so he thought it would be smarter to beforehand prepare the QR codes in some kinda field of each individual record, and then during printing just insert that same record.
But for now we just wanna generate the QR code in any way shape or form.

Id appreciate a link to a guide or just a simple example code.
 
Code:
                                                    m.LOFBC = CREATEOBJECT("FoxBarcodeQR")
                                                    m.BARCODEIMAGE = ""  && the code you want in the QR image
                                                    m.BARCODESIZE = 2
                                                    m.BARCODEFILE = m.TEMPDIR+"qrcode.jpg"
                                                    m.LOFBC.QRBARCODEIMAGE(m.BARCODEIMAGE, m.BARCODEFILE, m.BARCODESIZE, 1)
                                                    m.LOFBC = NULL

Above makes a .jpg file... in the folder specified in m.TEMPDIR using the FoxBarcodeQR barcodelibrary.dll you can put https://mywebsite.com/process.asp?image=xyy
in the code image
 
Last edited:
Code:
                                                    m.LOFBC = CREATEOBJECT("FoxBarcodeQR")
                                                    m.BARCODEIMAGE = ""  && the code you want in the QR image
                                                    m.BARCODESIZE = 2
                                                    m.BARCODEFILE = m.TEMPDIR+"qrcode.jpg"
                                                    m.LOFBC.QRBARCODEIMAGE(m.BARCODEIMAGE, m.BARCODEFILE, m.BARCODESIZE, 1)
                                                    m.LOFBC = NULL

Above makes a .jpg file... in the folder specified in m.TEMPDIR using the FoxBarcodeQR barcodelibrary.dll you caam put https://mywebsite.com/process.asp?image=xyy
in the code image
Hey Griff thanks for the code, would you mind going in a visual fox pro and creating like an example and taking a screenshot, Right now i don't have access to visual fox pro because my device is being repaired away from me, and i'm currently working from home, could you perhaps make a little report with that QR and just send a screenshot of the code and that QR code?

Thanks in advance :)
 
This won't be the only way to do it but what we do is have a program which can be called from anywhere in the application, in a routine for generating the QR codes, or on a picture object on the report layout. For us the program is called get_qrcode, we pass in the data required to generate the URL which is embedded in the QR code, know where to store it and the program returns the full path to the QR code file on the network, which upon generation is an image, a PNG file stored in an appropriate place for the system to pick up each time is required.

There's plenty of specifics that are particular to us that you may not need to do but as a quick summary, the QR codes that we put on reports are for a vehicle catalogue for cars, vans, etc that are up for auction, the QR code has the URL for consumers of the catalogue to scan and be taken to the web page of that auction listing. For us that means 1 QR code per vehicle in the database, it doesn't need to change during the lifetime of that database record. That in turn means that the location where the image is stored on the network doesn't change. This means that when the QR code is generated the first time, each subsequent time the get_qrcode program is called, if it is for a vehicle where the image already exists the program can simply return the path of the already existing image, which is obviously faster than re-generating it each time it is required.

If the image doesn't exist yet for the required vehicle, the program calls the appropriate method for generating it. Our method of QR code generation has changed over time. The first method used Google charts API, something along the lines of:

Code:
https://chart.googleapis.com/chart?cht=qr&chs={dimensions}&chld=Q&chl={dataToEmbed}

...and we'd use the WinAPI URLDownloadToFile to call that URL and download the result to a file. We've also integrated FoxBarcodeQR as another method, I can't remember if it was just for redundancy or if we had a problem calling the Google Charts API but regardless, when you rely on a Google API it's always good to have a backup plan as Google have a terrible reputation for deprecating or changing their APIs.

So that's it: Call program with necessary details, program looks for existing image and returns path if it exists, if not it generates the image by calling one of the integrations (either Google Charts or FoxBarcodeQR) and storing the file for current and future use.
 
Thanks Paul, I'm not the best at fox but I'm sure my programmer will be able to learn from this greatly!
I think it resembles the same logic we are aiming to achieve.
 

Part and Inventory Search

Sponsor

Back
Top