Home > ERP, Technology > Solution: BI Publisher QR Codes

Solution: BI Publisher QR Codes

I saw a post on StackOverflow asking How to use variable in chart.apis.google link for QR Code and I was quite intrigued. I didn’t think it could be done at first. But then I figured it out.

I do know that BI Publisher has built in Chart support, so my first thought was to just use that. But BI Publisher charting cant generate QR Codes. None the less, I linked to BI Publisher Report Designers guide to explain those details if anyone stumbled upon this post looking for actual charts.

My second thought was to follow a blog entry that an Oracle developer posted about using QR Codes in BI Publisher. It mentioned making a java class, and using an IDAutomation QR Font. It was quite complex. This is probably the method to go after if you want all the data to remain internal to the Oracle server in the enterprises data-center. I posted the details to that too.

Finally, I remember using dynamic images at Emerson for insertion of Casting images into Work-orders/Shop-packets. I figured why not give it a shot. I created a quick XML test file, and a simple RTF file. I use the concat (concatenate) function in BI Publisher to combined the Google Charts API for QR codes and the variable I wanted encoded.

Test XML

<test_header>
<test_row>
<row_num>1</row_num>
<value>TESTA</value>
</test_row>
<test_row>
<row_num>2</row_num>
<value>TESTB</value>
</test_row>
</test_header>

Test RTF Template

RTF Template

RTF Template

Image ALT TEXT

url:{concat(‘https://chart.apis.google.com/chart?cht=qr&chs=500×500&choe=UTF-8&chld=H&chl=’,value)}

[when copy/pasting from this page, replace the x in the URL with one hand-typed.]

My first attempt failed because of a space in my test data. If you have spaces or special characters in the data you want encoded in the QR code, make sure you URL encode the data that you want to pass into the Google API URL. Oracle allows you to do this with the UTL_URL function. Also note: this post is being made with WordPress, the single quotes are improperly being replaced with smart quotes and/or HTML entities… use care if copying and pasting, and make sure to use the single quote as per screen shot.

Example use of UTL_URL.ESCAPE

select rownum row_num, utl_url.escape(record_value) value from test_table

Once I removed the space from my test data, it worked! I was shocked how easy it could be.

Test Output

PDF Output

PDF Output

Other Considerations

One last thing to note, if you expect this to work on your enterprise server/network/data-center, you’ll probably have to open up the firewall.

  1. Nadeem Abbasi's avatar
    Nadeem Abbasi
    October 8, 2020 at 1:20 AM

    hi ,
    I want to generate barcode using the same API discussed above, is it possible?

    • October 8, 2020 at 9:52 AM

      I’m not sure what you mean. If you want to generate a standard CODE 3of9, use a CODE 3of9 font, add to BI Publisher as an embedded font. There’s paid for and public fonts available on the internet.

  2. Vimal Kumar's avatar
    Vimal Kumar
    May 5, 2021 at 12:47 PM

    Thanks for sharing it. Very useful one

  3. Brian Bayley's avatar
    Brian Bayley
    June 14, 2021 at 7:05 AM

    This is the command that worked for me: url:{concat(‘https://chart.apis.google.com/chart?cht=qr&chs=500×500&choe=UTF-8&chld=H&chl=’,value)} Was getting errors until I removed the “&#8217” value from this post. Then this worked great! Thanks.

    • June 14, 2021 at 8:57 AM

      Good catch Brian! WordPress is acting funny with the quote in the string. I attempted to fix it, and also added a note to the post. Thanks for pointing this out! Posting code on WordPress can be tricky.

  4. Shad's avatar
    Shad
    July 13, 2021 at 3:17 AM

    Hi! Thanks for this post. I think this is really helpful in my requirement in generating QR codes in BI Publisher. However, what I need is a string value to be converted into a QR code. Do I just replace the “value” element with the string variable in my XML?

  5. daniyal's avatar
    daniyal
    September 14, 2021 at 5:45 AM

    copied the same steps, end output is blank ? any suggestions

    • September 15, 2021 at 9:44 AM

      Hard to tell without seeing your code.

  6. Mohan's avatar
    Mohan
    April 7, 2022 at 11:01 AM

    I would like Print QR code for Purchase Order number .I was getting xml TAG as SEGMENT1.url:{concat(‘https://chart.apis.google.com/chart?cht=qr&chs=500×500&choe=UTF-8&chld=H&chl=’,SEGMENT1)}..Its not working, Could you please help on this

    Regards,
    Mohan

    • April 13, 2022 at 1:42 PM

      Sorry, WordPress did something funky with the “x” in the URL for the dimensions, replace that with a standard “x’ that you hand-type.

  7. Siva's avatar
    Siva
    October 17, 2022 at 7:37 AM

    When i scan using QR code it is not showing any values..

  8. siva's avatar
    siva
    October 17, 2022 at 7:40 AM

    I am using this part of code in RTF template to print on PDF and QR code is displayed .

    url:{concat(‘https://chart.apis.google.com/chart?cht=qr&chs=500×500&choe=UTF-8&chld=H&chl=’,ITEM_DESCRIPTION)}

    able to scan but not giving/displaying any values.

    • October 21, 2022 at 9:09 PM

      Please see previous comment above.

  9. narendra's avatar
    narendra
    June 29, 2023 at 6:05 AM

    Unable to scan the qr code with above URL tag. Any help?

    • June 29, 2023 at 7:19 AM

      Did you copy paste and fix the “x”?

      • narendra's avatar
        narendra
        July 8, 2023 at 7:46 AM

        Yes I modified the “x”.

      • narendra's avatar
        narendra
        July 8, 2023 at 11:47 PM

        its working , based on size of the image 500×500 these numbers should change. Now I am able to scan and showing the value.

    • narendra's avatar
      narendra
      July 9, 2023 at 11:46 PM

      Hi Ed Hayes, The problem is when display QR code in Header and Footer section with above url, unable to scan, due to XML data in inside group. Any help

    • narendra's avatar
      narendra
      July 10, 2023 at 2:10 AM

      url:{concat(‘https://chart.apis.google.com/chart?cht=qr&chs=500×500&choe=UTF-8&chld=H&chl=’,.//value)}

      this way I can able to get the value (,.//value)

      • July 10, 2023 at 8:25 AM

        If you are still having issues, post something on Stackoverflow, and post the link here. Make sure to included the XML and template code.

  10. narendra's avatar
    narendra
    July 8, 2023 at 7:18 AM

    Yes I did.

  11. narendra's avatar
    narendra
    July 12, 2023 at 11:52 PM

    No issue, I am able to scan and get the value.
    below is the url I used. .//value –> This denotes under how many no of roots(//). I need to mention that many slashes(/).

    url:{concat(‘https://chart.apis.google.com/chart?cht=qr&chs=500×500&choe=UTF-8&chld=H&chl=’,.//value)}

  1. No trackbacks yet.

Leave a comment