New User? Sign Up  |  Sign In  |  Help
Barcode support and
tutorials from IDAutomation
and the community.
Click for the BBB Business Review of this Computers Hardware, Software & Services in Tampa FL
Resolved Questions

DataMatrix Library Issue with Postscript Font in VBScript

We purchased the 2D DataMatrix Font Developer Package, and have yet to get it to work. I need to call the postscript font using VBScript, I have looked online and read the documentation,
I am either not understanding how to do it, or not finding anything on it.

DataMatix Encoder App has been installed on a Local Machine running Windows 10 Enterprise
DLL has been registered
2D Postscript font has been installed

My last attempt had me calling the VBScript Encoder Text File that was delivered with the package, and the font is coming out
like a linear barcode, but at least I'm getting output, was never able to get output using the library which is my preferred method.
Sample PDF Attached of linear output using VB Script Text File Function.

Here is the code I used to try and call the postscript font using VB Script. Bold Text is everything related to the Encoder

'SET CONSTANT
Const ForReading = 1
Const ForAppending = 8
Const ForWriting = 2

'DECLARE VARIABLES
Dim fso, ps

Set fso = CreateObject("Scripting.FileSystemObject")
Set dmFont = CreateObject("IDAuto.Datamatrix") 'ACCESS TO THE DATA Matrix Library which is not working for me and is my preferred method of calling encoder
Set dmEncoder = fso.OpenTextFile("C:CylanceSafeprojects2DBarcodedmEncoder.vbs", ForReading) 'Ended up trying this, I at least got output. PDF file attached. Coming out linear

Execute dmEncoder.ReadAll() 'Read in entire Encoder file (VBScript Encoder.txt)

strFileName = "DMBarcode_Test.ps"
Set ps = fso.OpenTextFile("c:cylancesafeprojects2DBarcode" & strFileName, ForWriting, True)

Call PostScriptHeader()

ps.WriteLine("10 /LetterGothic-Bold font")
ps.WriteLine("4.50 inch 9.25 inch moveto")
ps.WriteLine("(SEQ001-000001) show")

ps.WriteLine ("DMBarcode") 'Postscript Font defined in Postscript Header, My definition may be why it is coming out linear, wasn't sure how to call it
ps.WriteLine("4.63 inch 10.17 inch moveto")
dmBarcode =EncNDM("001-000001") 'Calling Function in VBScript Encoder Text File

'dmBarcode = EncDM("001-000001", 0, 0, -1) 'Commented out can not get to work. Call to EncDM sub below
ps.WriteLine ("(" + dmBarcode + ") show")

ps.WriteLine ("showpage")

ps.WriteLine("")
ps.WriteLine("")


ps.Close

WScript.Echo "Complete"
'*****
'Preferred Method of Encoding DataMatrix font through library that is not working for me.

Public Function EncDM(DataToEncode, ProcTilde, EncMode, PrefFormat)


EncDM = dmFont.FontEncode(DataToEncode, ProcTilde, EncMode, PrefFormat, "DM")

End Function

'*****
Sub PostscriptHeader()

PS.WriteLine("/font {findfont exch scalefont setfont} bind def")
PS.WriteLine("/inch {72 mul} def")
PS.WriteLine("/box {exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath} bind def")
PS.WriteLine("/center {dup stringwidth pop 2 div neg 0 rmoveto} bind def")
PS.WriteLine("/rightshow {dup stringwidth pop 20 exch sub 0 rmoveto show} bind def")
PS.WriteLine("/wordbreak ( ) def")

PS.WriteLine("/int2of5a {/Interleaved2of5 findfont [36 0 0 12 0 0] makefont setfont} def") '******one line barcode
PS.WriteLine("/int2of5 {/Interleaved2of5 findfont [36 0 0 36 0 0] makefont setfont} def")
PS.WriteLine("/int2of5b {/Interleaved2of5 findfont [36 0 0 24 0 0] makefont setfont} def") '****two line barcode

PS.WriteLine("/imbuc23pp {/UC23PP findfont 9.12 scalefont setfont} def")
PS.WriteLine("/int2of5s {/Interleaved2of5 findfont [30 0 0 30 0 0] makefont setfont
PS.WriteLine("/int2of5bms {/Interleaved2of5 findfont [36 0 0 28 0 0] makefont setfont} def") 'Booklet Maker Barcode Small
PS.WriteLine("/DMBarcode {/IDAutomation2D findfont [12 0 0 12 0 0] makefont setfont} def") 'Defining size and name of DataMatrix Postscript font

PS.WriteLine("%%%EH")
PS.WriteLine("")
PS.WriteLine("")

Operating System: Windows 10

Application: VBS Edit and Adobe Acrobat Professional
Attachments:

11-13-23     167 day(s) ago    

  Report Abuse

 

Brant

Best Answer

The customer reports that they incorporated a break-into-lines function written for postscript into the VBScript Encoder.txt file and were able to get the barcode to wrap.

We do not recommend using the COM DLL because Microsoft has deprecated this technology. However, if you really want to use it, you must install the EXE included in the package. After that, Access the function by creating another function. You can also refer to the projects in the "ActiveX Control and DLL" folder of the file.

Example from Excel VBA:

Option Explicit
Public Function EncDM(DataToEncode As String, Optional ProcTilde As Integer = 0, Optional EncMode As Integer = 0, Optional PrefFormat As Integer = 0) As String
'Format the data to the Data Matrix Font by calling the ActiveX DLL:
Dim DMFontEncoder As DMATRIXLib.Datamatrix
Set DMFontEncoder = New Datamatrix
DMFontEncoder.FontEncode DataToEncode, ProcTilde, EncMode, PrefFormat, EncDM
End Function

Posted 164 day(s) ago

(1)
(0)
  Report Abuse
 
Find Interesting
 
Email to Others
 
Bookmark
 
Subscribe to Answer Alert
No comments yet.     Be the first to comment.
Other Answers (4)
So the truetype font works fine. I tried to use the postscript font through VBA and Microsoft Access calling the .bas module, and received the same results of the barcode breaking into 4 pieces. All of our work is only done postscript, so we can not use the truetype font, it has to be the postscript font. Could it possibly be the way I'm defining the font in postscript? Is there another suggested method? This is what I am using:
/DMBarcode {/IDAutomation2D findfont [12 0 0 12 0 0] makefont setfont} def

Posted 166 day(s) ago

(0)
(0)
   Report Abuse
From the image attached, your barcode is being generated, however, it is not being stacked properly. Something is not interpreting the vbCrLf properly. Can you try uninstalling the PostScript font and install only the TrueType font and then let me know if you have the same issue? You can see in the VB Script the lines that insert the return - this is the same as vbCrLf:
Next ' i1 'Insert a space + a return
fontText = fontText + ChrW(32) + ChrW(13) + ChrW(10)

Also, you can try running the Excel Font Encoder App in the product as an alternative solution or for troubleshooting purposes. It uses VBA which is similar to VB Script.

Posted 166 day(s) ago

(1)
(0)
   Report Abuse
We are using VBS Edit by Adersoft (VB Script) for the coding, and Acrobat Distiller (Acrobat Pro DC) for the postscript font. I'm still not understanding why the COM object is not working, and why I am having to use text file function encNDM. For CRLF we use vbCrLf.

Posted 166 day(s) ago

(0)
(0)
   Report Abuse
I’m not sure which application you’re using, but depending on the application, you you may need something different to tell the application that the next data is a new line. So after each chunk of barcode data, you need a line feed. There is a portion you could modify in the code to change that, but the application doesn’t look like it’s recognizing it because the default is CRLF. Which application are you using?


Posted 167 day(s) ago

(0)
(0)
   Report Abuse
Email this question link to friends
You must enter an email address, if name is entered or vice-versa for each friend.
Friend #1 -
Friend #2 -
Friend #3 -
Friend #4 -
Friend #5 -
  Your comment on this question
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must starts with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always starts with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 Characters are allowed. Current Count: 0
  Your comment on this answer
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allow you to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must start with "http://" or "https://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always start with "http://" or "https://")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 characters are allowed. Current Count: 0

You may answer and comment on any thread according to the Terms and Conditions.

 © Copyright 2021 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook