Forums

Generate barcode from field in Thank you message or E-mail

abhishekpatil 17 Mar, 2017
Hello Genius,
I am using Chronoforms5 and I want to show a barcode from input field in thank you message. What should I do?
In addition to that, I am using Joomla 3.6.5 and I want to add a field in user details so that I can directly create a barcode without taking details in form everytime. In this case, input data is roll number of student. I want to generate barcode of their roll number on thank you message.

Thank You in advance, Special thanks to GreyHead in Advance.
GreyHead 17 Mar, 2017
1 Likes
Hi abhishekpatil ,

You can use PHP in a Custom Code action to create a barcode image. There's an example in this thread using Charles Schefford's barcode.php file - I couldn't find that on-line in a quick search but there's a similar library on GitHub here

Bob
abhishekpatil 17 Mar, 2017
Thank you so Much for your quick reply, Thats what I expected from you. I will try it just now. As I am unable to send PM to you now, I will post my reply here.

Thank you.
abhishekpatil 17 Mar, 2017
Hello GreyHead,
When I tried your solution, I found some following things-
1. It generating barcode on form (in attachment) , I want its code so that I can Show it anywhere like in Email or Thank you message or in PDF.

2. I dont want to generate random id, I just want barcode from input alphanumeric field.

Please do something...
GreyHead 17 Mar, 2017
1 Likes
Hi abhishekpatil ,

You don't need to use the part of the code that creates the random string. Just use the input value from the $form->data array.

Once you have saved the image then you can include that as an image link in an email (remember to use the full URL) or in the thank you message or PDF.

Bob
abhishekpatil 17 Mar, 2017
Can't I use it without saving on server?
Is it possible to directly generate in PDF or Thank you message?
GreyHead 17 Mar, 2017
1 Likes
Hi abhishekpatil ,

Possibly but I wouldn't try. You could use a cron job to delete any files after say 24 hours if storage is the problem.

Bob
abhishekpatil 17 Mar, 2017
If its simple for you to take inputt value from form and generate barcode then will you provide its code please?

Thank you for your continuous guidance.
GreyHead 17 Mar, 2017
1 Likes
Hi abhishekpatil,

To echo it out in a Thank you page it would be something like this
<?php
echo "<img src='".JURI::base()
."components/com_chronoforms5/extras/barcode/barcode.php?barcode="
.$form->data['input_name']."&width=320&height=80' />";
?>
Looking at my old notes that should also work in an email

Bob

PS You can get the barcode.php file here
abhishekpatil 18 Mar, 2017
Thank you for the code, I have some doubts,

1) $form->data array is not working in thank you page, something went wrong. I have attached the screenshot.

2)To echo it out in thank you page, which addition should I do in Form code? If its possible, will you provide that?
It should not random code. It should input alphanumeric field from which barcode should be generated in Destination i.e. in Thank you page or Email.

3)How can I save it on server so that I will able to give a link through HTML in Thank you page?
GreyHead 18 Mar, 2017
Hi abhishekpatil,

Sorry, the Thank You page action does not support PHP (I forget that); use a custom Code action instead.

Replace input_name in my example with the name of the input with the value you want to add to the barcode.

Bob
abhishekpatil 18 Mar, 2017
Answer
Thank you,
Also,
How can I save it on server so that I will able to give a link through HTML in Thank you page?
abhishekpatil 18 Mar, 2017
From your reply,
I got an idea that,
I can show last message as a custom code instead of 'Show message'.
I got success to show barcode from input.

But there is another problem. I need a print button which will print data.
I have added to it. But when I click on it, barcode dissapears from print. What should I do?
GreyHead 18 Mar, 2017
Hi abhishekpatil,

This seems to work OK
<?php
$path = JPATH_SITE.'/components/com_chronoforms5/uploads/barcodes/';
copy(JURI::base()
."components/com_chronoforms5/extras/barcode/barcode.php?barcode="
.$form->data['input_name']."&width=320&height=80", $path.$form->data['input_name'].'.jpeg');
?>
You may need to change the file name to avoid problems with duplicates.

Bob
abhishekpatil 18 Mar, 2017
According to me,
this barcode is not in Image format, it is in form of php code, thats why it diappears on print action. What should I do?
abhishekpatil 18 Mar, 2017
what will happen if I saved barcode on server and placed its link? Will print function print it?

How can I do that?

How can I save barcode on server? And how to get its link? will you provide its code?
GreyHead 18 Mar, 2017
Hi abhishekpatil,

Please check my last post.

Bob
abhishekpatil 18 Mar, 2017
Surely your solution works very well, But how to echo it out in custom code? Provided code is just saving img file. How to show it?
GreyHead 18 Mar, 2017
Hi abhishekpatil,

You can echo it out directly with the first code I added, or save it then show it using an <img> tag like any other image file.

Bob
abhishekpatil 19 Mar, 2017
1 Likes
Yeah!

Done!
I get what I want exactly!
Thank you so much.

I just kept your code in on submit event so that it will save barcode on server.
After that added a simple html link of it in another custom code after previous one!

Also now I am able to print it.

The simple HTML code is
<img src='/components/com_chronoforms5/uploads/barcodes/{Input_field}.jpeg?i=1'' />


Now you can mark this topic as Solved!
I will surely come back with new questions and doubts for your brave brain.
Thank you again.
This topic is locked and no more replies can be posted.