Writing Barcode jpg to disk file
3 posts • Page 1 of 1
Writing Barcode jpg to disk file
Hi--
We are using version 3.2 and are, so far, not able to use the 'ExportImage' method to write a jpg image to a folder on our server. The dll is creating a foo.jpg file, but it is shown as broken (red 'X') in a viewer. I opened one of the files with a hex editor and it appears to have the barcode information in it, but as ascii text, not binary data. I'm including the snippet of classic ASP that is calling the dll.
Any and all help is deeply appreciated!!
Dim objBarcode, objStream
Set objBarcode = Server.CreateObject("Morovia.BarcodeActiveX") objBarcode.RasterImageResolution = 96 objBarcode.BorderStyle = 0 objBarcode.ShowComment = false objBarcode.ShowHRText = trueobjBarcode.SymbolMarginTop = 100objBarcode.Symbology = 5 objBarcode.NarrowBarWidth = Request.QueryString("NarrowBarWidth")objBarcode.BarHeight = 500
objBarcode.Message = Request.QueryString("Message") & ".jpg"
objBarcode.ShowHRText = Request.QueryString("ShowHRText")
objBarcode.Font.Size = 9
objBarcode.Font.Name = "Arial"
objBarcode.Font.Bold = True
objBarcode.ShowComment = false
IF (objBarcode.Symbology = mbxInterleaved_2of5 ) THEN
objBarcode.Font.Bold = false 'SCC14 printed with normal font style
objBarcode.BearerBars = true 'Add bearer bars to SCC14
END IF
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.Open
objBarcode.ExportImage objStream, 1
objStream.Position = 0
objStream.SaveToFile "D:\Tradein\Motorola\TradeIn\Barcodes\" & Mailer_label & ".jpg" , 1
'Response.write "<br>Image: <img src='" & Mailer_label & ".jpg' >"
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
Set objBarcode = Nothing
Thanks in advance--
--Jim
We are using version 3.2 and are, so far, not able to use the 'ExportImage' method to write a jpg image to a folder on our server. The dll is creating a foo.jpg file, but it is shown as broken (red 'X') in a viewer. I opened one of the files with a hex editor and it appears to have the barcode information in it, but as ascii text, not binary data. I'm including the snippet of classic ASP that is calling the dll.
Any and all help is deeply appreciated!!
Dim objBarcode, objStream
Set objBarcode = Server.CreateObject("Morovia.BarcodeActiveX") objBarcode.RasterImageResolution = 96 objBarcode.BorderStyle = 0 objBarcode.ShowComment = false objBarcode.ShowHRText = trueobjBarcode.SymbolMarginTop = 100objBarcode.Symbology = 5 objBarcode.NarrowBarWidth = Request.QueryString("NarrowBarWidth")objBarcode.BarHeight = 500
objBarcode.Message = Request.QueryString("Message") & ".jpg"
objBarcode.ShowHRText = Request.QueryString("ShowHRText")
objBarcode.Font.Size = 9
objBarcode.Font.Name = "Arial"
objBarcode.Font.Bold = True
objBarcode.ShowComment = false
IF (objBarcode.Symbology = mbxInterleaved_2of5 ) THEN
objBarcode.Font.Bold = false 'SCC14 printed with normal font style
objBarcode.BearerBars = true 'Add bearer bars to SCC14
END IF
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.Open
objBarcode.ExportImage objStream, 1
objStream.Position = 0
objStream.SaveToFile "D:\Tradein\Motorola\TradeIn\Barcodes\" & Mailer_label & ".jpg" , 1
'Response.write "<br>Image: <img src='" & Mailer_label & ".jpg' >"
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
Set objBarcode = Nothing
Thanks in advance--
--Jim
- jhowell(Legacy Member)
Re: Writing Barcode jpg to disk file
Jim,
We examined your source code and found that you used QueryString to get several parameters. It would be better to check if an invalid value is passed.
(1) I suspect that you did not pass the NarrowBarWidth. So it becomes 0. This makes the barcode disappear. I would suggest you change to something below
If (CInt(Request.QueryString("NarrowBarWidth")) < 10 ) Then
objBarcode.NarrowBarWidth = 10
Else
objBarcode.NarrowBarWidth = Request.QueryString("NarrowBarWidth")
End If
Note - since you specify the image to be created under 96 dpi, you should not pass a value below half of the pixel size (5 mils) to NarrowBarwidth. Otherwise the program will round it to 0.
(2) I also have questions on this statement:
objBarcode.Message = Request.QueryString("Message") & ".jpg"
This statement will throw an expcetion for numeric symbologies such as Code25 and Interleaved 2 of 5, since they only encode numeric data.
We modified your script a little bit and it runs well on our server. Let me know if they work for you.
Edited by glitch on June 22 2006 at 12:08pm
We examined your source code and found that you used QueryString to get several parameters. It would be better to check if an invalid value is passed.
(1) I suspect that you did not pass the NarrowBarWidth. So it becomes 0. This makes the barcode disappear. I would suggest you change to something below
If (CInt(Request.QueryString("NarrowBarWidth")) < 10 ) Then
objBarcode.NarrowBarWidth = 10
Else
objBarcode.NarrowBarWidth = Request.QueryString("NarrowBarWidth")
End If
Note - since you specify the image to be created under 96 dpi, you should not pass a value below half of the pixel size (5 mils) to NarrowBarwidth. Otherwise the program will round it to 0.
(2) I also have questions on this statement:
objBarcode.Message = Request.QueryString("Message") & ".jpg"
This statement will throw an expcetion for numeric symbologies such as Code25 and Interleaved 2 of 5, since they only encode numeric data.
We modified your script a little bit and it runs well on our server. Let me know if they work for you.
Edited by glitch on June 22 2006 at 12:08pm
- glitch(Legacy Member)
Re: Writing Barcode jpg to disk file
Glitch--
Thanks for the quick reply. We are testing this right now.
Best Regards --Jim
Thanks for the quick reply. We are testing this right now.
Best Regards --Jim
- jhowell(Legacy Member)
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest