Greetings everyone,
I am currently searching the internet for information and samples on TIWJQueryWidget, but unfortunately, I have not been successful in finding any relevant resources. My aim is to present a barcode on an Intraweb page. However, I am facing difficulties in implementing TIWJQueryWidget.
I would be grateful for any assistance you could provide. Thank you.
0 Jhon773/12/2015
To display a barcode in an Intraweb page using the TIWJQueryWidget component, you can use a JavaScript library such as JsBarcode.
Here are the steps to do it:
Download the JsBarcode library from the official website: https://github.com/lindell/JsBarcode
Extract the downloaded files and copy the "JsBarcode.all.min.js" file into your Intraweb project directory.
In your Intraweb form, add a TIWHTMLPanel component and set its Height and Width properties to the size you want the barcode to be.
In the OnRender event of the TIWHTMLPanel, add the following code:
procedure TForm1.IWHTMLPanel1Render(Sender: TObject);
var
BarcodeValue: string;
BarcodeCanvas: TIWCanvas;
begin
BarcodeValue := '123456789'; // Set the value of the barcode here
BarcodeCanvas := TIWCanvas.Create(Self);
try
BarcodeCanvas.Width := IWHTMLPanel1.Width;
BarcodeCanvas.Height := IWHTMLPanel1.Height;
BarcodeCanvas.JSInterface.JSCode.Add('JsBarcode("#' + IWHTMLPanel1.HTMLName + '", "' + BarcodeValue + '");');
IWHTMLPanel1.Canvas.Draw(0, 0, BarcodeCanvas);
finally
BarcodeCanvas.Free;
end;
end;
In the Uses section of your unit, add the following line:
IWHTMLCanvas;
This will allow you to use the TIWCanvas component.
Finally, in the OnBeforeRender event of your form, add the following line to include the JsBarcode library in your page:
IWBSCommon.AddScriptFile(Self, 'jsbarcode.all.min.js');
That's it! When you run your Intraweb application, the barcode should be displayed in the TIWHTMLPanel. Note that you can change the value of the barcode by modifying the BarcodeValue variable in the OnRender event.