0

I am using the QR Coder library in C# to generate QR codes that will go to a URL with a Token in the Query String. https://github.com/codebude/QRCoder

Currently, I can Print Preview all the QR Codes, but without a Token showing beneath it.

I need to display a string below the QR Code image with a Token Code when I click on the Print Preview button. This will fetch all the QR Code images and show them on the Print Preview window.

enter image description here

The Print Preview button will fetch all the Tokens generated, append them to a link and finally generate the base64 string for the QR Image that is sent to a JavaScript Print method.

I am using Print JS: https://printjs.crabbly.com/

Below is my JavaScript method below with the following code (Multiple Image Mode):

function printAllQRCodesForProduct(base64, printwidth) {
   printJS({ printable: **base64**, type: 'image', imageStyle: 'width:' + printwidth + '%;margin- 
   bottom:10px; float:left; margin-right:10px;' });  
}

It does not seem that Print JS can allow you to have multiple image captions. If this was the case, that would work. Perhaps I can modify the Print JS code or perhaps is it possible to somehow take the generated Base64 image QR code and append a string with the Token text just below it without having to render the image on a Canvas tag and then re-saving it as a Base64 string? Can all this be done on the Code-Behind in C#?

So in summary, is it possible to modify a base64 generated image with another image and combine them, or is there a way to add text and get a new base64 image string?

Tig7r
  • 525
  • 1
  • 4
  • 21
  • 2
    presumably the image would be encoded in some image format, and most formats do not allow enlargement by simple concatenation. So you would need to decode, modify and re-encode the image. – JonasH Aug 04 '21 at 18:29
  • 1
    @JonasH or, if it's sufficient to just _show_ it on the print preview, but not necessarily part of the actual image, just send the string separately and show it underneath using html. Base64 does not use characters like the semicolon, so it could be appended behind the Base64 separated by a semicolon, then split off at the other end before the image data is shown. – Nyerguds Aug 24 '21 at 11:07

1 Answers1

0

I see that it is possible to add text to a generated Bitmap in C#.

Found the answer on this post: c# write text on bitmap

Tig7r
  • 525
  • 1
  • 4
  • 21