Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3786134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:38:08+00:00 2026-05-19T11:38:08+00:00

I have a barcode that I am dynamically generating, and want to pass to

  • 0

I have a barcode that I am dynamically generating, and want to pass to a gsp that will later become a pdf. I do not need to persist the barcode for any of my own purposes, and would like to simply pass the image from the controller to the gsp.

Is there a way to render an image that is passed as a variable rather than specifying a src?

Thanks in advance.

EDIT:

Since I am generating the pdf from the gsp, I am flushing the output stream of the response then, and therefore cannot do it with the image also, or I get an error.

Furthermore, using javascript/jQuery does not work since the page is never rendered directly by the browser.

It may look like the only option I have is to persist the images temporarily somewhere, and then delete them…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:38:09+00:00Added an answer on May 19, 2026 at 11:38 am

    I answered a similar question recently, perhaps its answer will work for you. I’ll paste a portion of it here. It’s basically Oded’s “outside of this…” suggestion.

    class BarcodeController {
        def index = {
            def img // byte array, set this to the binary contents of your image
    
            response.setHeader('Content-length', img.length)
            response.contentType = 'image/png' // or the appropriate image content type
            response.outputStream << img
            response.outputStream.flush()
        }
    }
    

    You could then access your image in the src of an tag like this:

    <img src="${g.link(controller: 'barcode', action: 'index')}"/>
    

    This answer seems to fit the last comment you made on the question (about a similar solution using PHP).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to print a barcode that is generated by our system. I have
I have an application that reads a barcode, extracts a part and checks if
I have an array of bytes that has come from a barcode reader (connected
I have a barcode reader and bunch of books. For each of the books,
I have a textbox on an asp.net page. I use a barcode scanner to
I can't find quite the answer I'm looking for anywhere. I have a plugin
I have code like this: // Create event handler delegate symbolReader.ReadNotify += new EventHandler(symbolReader_ReadNotify);
I have a question which I see from googling has been discussed at length..
We are designing a mobile shopping system. The camera on the phone will read
We are designing a mobile application which reads barcodes of the products and get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.