This relates my Code 128 font problem.
In Acrobat DC, using my old version of _javascript_, the Code 128 font only drew as rectangles in new text boxes. I could manually draw a new text box in the document, and set its contents to Code 128 OK, so I thought my _javascript_ needed updating.
Trouble is, I get a ‘can’t understand script’ message when running it.
An abbreviated version of the code is below. Would anyone with knowledge of Java mind telling me what I’m doing wrong, please?
Of note, Using my old _javascript_ version, I can select the new text boxes, but cannot select and change the font of the displayed rectangles. If I hit Command-A while a text box is selected, then hit delete, the rectangles disappear, then I can type in new text, and it displays as the bar code 128 font. Darned if I know what’s wrong!
I also assume THIS below might have a bearing on my problem, but can’t get access to the Java Editor in El Capitan Acrobat DC.
tell application "Adobe Acrobat"
activate
set p to 1
tell document 1
tell page 1
set cbox to {}
if cbox = {} then set cbox to crop box
if cbox = {} then set cbox to bounds
if cbox = {} then set cbox to media box
if cbox = {} then set cbox to art box
if cbox = {} then set cbox to trim box
if cbox = {} then set cbox to bleed box
set p to 4
set pageTop to (item 2 of cbox) + 36
set p to 5
set item 2 of cbox to pageTop
set p to 6
set pageBottom to (item 4 of cbox)
set p to 7
set item 4 of cbox to pageBottom
set p to 8
set bounds to cbox
set p to 9
set media box to cbox
set p to 10
set crop box to cbox
set p to 11
set trim box to cbox
set p to 12
set bleed box to cbox
set p to 13
set art box to cbox
set p to 14
set theNewString to ((character id 209) & "this is a test" & (character id 211) as text)
#
# values are Text, Font, Font Size, Start Page, End Page, Text type?, Horizontal Alignment, Vertical Offset, Horizontal Offset, Vertical Height, Rotation, Current Page
set p to 15
end tell
set theResult1 to my Add_WaterMarkText(theNewString, "Code 128", 48, 1, 1, 1, 0, 3, 10, 0, 0, 1)
# Generates a ‘doesn’t understand the “do script” message, see below.
do script theResult1
end tell
end tell
# This handler uses _javascript_
#
on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHorizontalAlignment, nVerticalAlignment, nHorizontalValue, nVerticalValue, nR, currentPage)
set theType to "FreeText" as text
set Params to "page:" & currentPage - 1 & ", " & return
set Params to Params & "type:" & theType & ", " & return
set Params to Params & "contents:" & cText & ", " & return
set Params to Params & "textFont:" & cFont & ", " & return
set Params to Params & "textSize:40, " & return
set Params to Params & "rect:[0, 0, 300, 100], " & return
set Params to Params & "width:0, " & return
set Params to Params & "alignment:0, " & return
set _javascript_ to "this.addAnnot({" & Params & "});"
return _javascript_
# OLD Script
(*set Params to "cText: '" & cText & "'," & return
set Params to Params & "cFont: '" & cFont & "'," & return
set Params to Params & "nFontSize: '" & nFontSize & "'," & return
if class of nS is integer then set Params to Params & "nStart: " & (currentPage - 1) & "," & return
if class of nE is integer then set Params to Params & "nEnd: " & (currentPage - 1) & "," & return
-- 0 = left, 1 = centre, 2 = right
if class of nHorizontalAlignment is integer then set Params to Params & "nHorizAlign: " & nHorizontalAlignment & "," & return
-- 3 = top, 4 = bottom
if class of nVerticalAlignment is integer then set Params to Params & "nVertAlign: " & nVerticalAlignment & "," & return
-- offset in points
if class of nHorizontalValue is integer then set Params to Params & "nHorizValue: " & nHorizontalValue & "," & return
-- offset in points
if class of nVerticalValue is integer then set Params to Params & "nVertValue: " & nVerticalValue & "," & return
if class of nR is integer then set Params to Params & "nRotation: " & nR & "," & return
set Params to Params & "bOnScreen: true" & "," & return
set Params to Params & "bOnPrint: true" & "," & return
set Params to Params & "bOnTop: true" & "," & return
set Params to Params & "nOpacity: 1.0" & "," & return*)
# set _javascript_ to "this.addWatermarkFromText({" & Params & "});"
end Add_WaterMarkText