Convert number to barcode Code 128

in the htmlviewer open event i had:

[quote]dim testbc as string
testbc = Code128(“test”)
me.LoadPage(".barcode { font-family: ‘Code128’ ; font-size: 60px; }

Das ist ein Test


<p class="“barcode”">" + testbc + “

”)[/quote]

is the result

create the file with folderitem

[quote]dim filestream as TextOutputStream
dim f as FolderItem = SpecialFolder.Desktop.Child(“report.html”)
dim htmlbox as string
dim htmlboxin as TextInputStream
dim htmlboxfile as FolderItem = SpecialFolder.Desktop.Child(“report.html”)
dim dl as new WebFile
msgbox(f.URLPath)
if f <> nil then
filestream = TextOutputStream.Create(f)
filestream.WriteLine(ConvertEncoding("", Encodings.UTF8))
filestream.WriteLine(ConvertEncoding("", Encodings.UTF8))
filestream.WriteLine(ConvertEncoding(“VOSA &#169 2019 by Stefan Beyer”, Encodings.UTF8))
filestream.WriteLine(ConvertEncoding("", Encodings.UTF8))
filestream.WriteLine(ConvertEncoding("", Encodings.UTF8))
filestream.WriteLine(ConvertEncoding(".barcode { font-family: ‘Code128’ ; font-size: 60px; }", Encodings.UTF8))
filestream.WriteLine(ConvertEncoding(“

VOSA Testbeleg


”, Encodings.UTF8))
end if
filestream.WriteLine(ConvertEncoding("<p class="“barcode”">" + Code128(“test”) + “

”, Encodings.UTF8))
filestream.WriteLine(ConvertEncoding("", Encodings.UTF8))
filestream.WriteLine(ConvertEncoding("", Encodings.UTF8))
filestream.Close
htmlboxin = TextInputStream.Open(htmlboxfile)
htmlbox = htmlboxin.ReadAll
htmlboxin.Close
auftraege.HTMLViewer1.LoadPage(htmlbox)
[/quote]

running created file in chrome

Label and pagesource as image

best regards

The HTML Viewer may actually be running in some compatibility mode on Windows
IF you switch the property on the HTMLViewer from “Native” to “Webkit” does that make a difference ?

can you give me a hint how to change the render engine?

click on your html vieer on your layout and open the inspector
select WebKit instead of Native

[quote=451363:@Norman Palardy]click on your html vieer on your layout and open the inspector
select WebKit instead of Native[/quote]

i cant find an option in the inspector

nm … this is why I asked if you were building a desktop application or a web app
this is a web application

When run it will run in whatever web browser you have installed on your machine that you can open & point at the web app
At that point its up to whatever web browser to handle the content and the font rendering

I’m not sure why you want to use an HTMLViewer
I’d draw the text of the bar code into a picture and then show that instead

Does this work for you Stefan?

https://www.dropbox.com/s/ec1u22gxe5m1ejn/TestCode128Picture.xojo_binary_project?dl=0

[quote=451391:@JulianS]Does this work for you Stefan?

Hi Julian,

thx for your help. As desktopapp this works fine, but on my webapp i get an OutOfBoundException. (Width/height needs to be in the range of 1-32767).

@all for explanation

The webapp i’m creating navigates warehouse staff to several places to collect the ordered items (this is working well). On the next step i want to create a label with all informations for the customer with barcodes and want to print the label via htmlviewer.print method. The Label should be printed after every correct pick. to do this the browser is set to always print silent in his settings. The warehouse staff has only to scan the item and the label should printed directly. Ive tested the printing and this is also working. My only Problem is to generate the barcode as image or display it as barcode in the htmlviewer.

Sometimes anyone has another suggestion?

Thanks again for your time to help.

Hi i found the bug by myself for the html way. ive forgot the space in the font-family name used ‘Code128’ instead of ‘Code 128’. Picture way would be nice too, but i dont get it working.

I just ran it in windows desktop & web and macos desktop & web without issue. The problem you’re getting is that the stringwidth and stringheight aren’t calculating correctly and are returning 0’s in a web project which shouldn’t be happening.

Is the machine you’re testing the web project on the same one that you tested the desktop project on? So the font is installed correctly?
What version of xojo are you using?
What version of macos are you using?

Give this a try, does it work for you?

https://www.dropbox.com/s/v94eoeph0xi8ioq/TestWebBarcode.xojo_binary_project?dl=0

[quote=451443:@JulianS]I just ran it in windows desktop & web and macos desktop & web without issue. The problem you’re getting is that the stringwidth and stringheight aren’t calculating correctly and are returning 0’s in a web project which shouldn’t be happening.

Is the machine you’re testing the web project on the same one that you tested the desktop project on? So the font is installed correctly?
What version of xojo are you using?
What version of macos are you using?

Give this a try, does it work for you?

Hi Julian,
i run the 2nd project and it crashes again with the same error. So i decide to check the fonts and there was the problem, after i reinstalled the font for all users, the code runs!

Thank YOU very much! I’m happy to get the problem solved :slight_smile:

P.S.: i’m running Xojo 2019r1 on a Dell XPS 13 with Win10 pro. This is the machine where i code and test all local. Now can i test both variants label generated by html with font & css and label with html and pictures. i think css and font has more performance but in this application after a current pick the app has 2 seconds for generating the label.

best regards from germany

Stefan