3838 }
3939
4040 // The Object Number of the AcroForm Dictionary
41- //var intern = this.internal;
42- // todo
4341 this . acroformPlugin . acroFormDictionaryRoot = new AcroForm . AcroFormDictionary ( ) ;
4442
45- //this.acroformPlugin.acroFormDictionaryRoot.DA = '(' + AcroForm.createDefaultAppearanceStream() + ')';
46-
47- //this.internal.events.subscribe('postPutResources', AcroFormDictionaryCallback);
48-
4943 this . acroformPlugin . internal = this . internal ;
5044
5145 // add Callback for creating the AcroForm Dictionary
226220 } ;
227221
228222
229- // ############### todo einsortieren!!!
223+ // ############### sort in:
230224
231225 /**
232226 * Button
@@ -1244,7 +1238,17 @@ AcroForm.TextField = function () {
12441238 }
12451239 } ) ;
12461240
1247- Object . defineProperty ( this , 'multiline' , { enumerable : false } ) ;
1241+ var _multiline = false ;
1242+ Object . defineProperty ( this , 'multiline' , {
1243+ enumerable : false ,
1244+ get : function ( ) {
1245+ return _multiline
1246+ } ,
1247+ set : function ( val ) {
1248+ _multiline = val ;
1249+ }
1250+ } ) ;
1251+
12481252 //this.multiline = false;
12491253 //this.password = false;
12501254 /**
@@ -1314,7 +1318,7 @@ AcroForm.internal.calculateFontSpace = function (text, fontsize, fonttype) {
13141318 var width = res . width ;
13151319
13161320 return res ;
1317- }
1321+ } ;
13181322
13191323AcroForm . internal . calculateX = function ( formObject , text , font , maxFontSize ) {
13201324 var maxFontSize = maxFontSize || 12 ;
@@ -1340,28 +1344,27 @@ AcroForm.internal.calculateX = function (formObject, text, font, maxFontSize) {
13401344
13411345
13421346 var height = formObject . Rect [ 3 ] - formObject . Rect [ 1 ] || 0 ;
1347+ height = ( height < 0 ) ? - height : height ;
13431348 var width = formObject . Rect [ 2 ] - formObject . Rect [ 0 ] || 0 ;
1349+ width = ( width < 0 ) ? - width : width ;
13441350
13451351 var isSmallerThanWidth = function ( i , lastLine , fontSize ) {
13461352 if ( i + 1 < textSplit . length ) {
1347- // For the last Blank (shouldn't be displayed)
1348- // var blankSpace = calculateFontSpace(" ", fontSize);
1349- var tmp = lastLine + " " + textSplit [ i + 1 ] ; // + " "
1353+ var tmp = lastLine + " " + textSplit [ i + 1 ] ;
13501354 var TextWidth = ( ( AcroForm . internal . calculateFontSpace ( tmp , fontSize + "px" , font ) . width ) ) ;
13511355 var FieldWidth = ( width - 2 * borderPadding ) ;
1352- //alert("Text: " + TextWidth + ", FieldWidth: " + FieldWidth);
13531356 return ( TextWidth <= FieldWidth ) ;
13541357 } else {
13551358 return false ;
13561359 }
13571360 } ;
13581361
13591362
1360- var text = "" ;
13611363 fontSize ++ ;
13621364 FontSize: while ( true ) {
1365+ var text = "" ;
13631366 fontSize -- ;
1364- var textHeight = AcroForm . internal . calculateFontSpace ( "e " , fontSize + "px" , font ) . height ;
1367+ var textHeight = AcroForm . internal . calculateFontSpace ( "3 " , fontSize + "px" , font ) . height ;
13651368 var startY = ( formObject . multiline ) ? height - fontSize : ( height - textHeight ) / 2 ;
13661369 startY += lineSpacing ;
13671370 var startX = borderPadding ;
@@ -1399,15 +1402,20 @@ AcroForm.internal.calculateX = function (formObject, text, font, maxFontSize) {
13991402 if ( ! formObject . multiline ) {
14001403 continue FontSize;
14011404 } else {
1405+ if ( ( ( textHeight + lineSpacing ) * ( lineCount + 2 ) + lineSpacing ) > height ) {
1406+ // If the Text is higher than the FieldObject
1407+ continue FontSize;
1408+ }
14021409 lastWordInLine = key ;
14031410 // go on
14041411 }
14051412 } else if ( isLastWord ) {
1406- if ( ( ( textHeight + lineSpacing ) * ( lineCount + 1 ) + lineSpacing ) > height ) {
1413+ lastWordInLine = key ;
1414+ } else {
1415+ if ( formObject . multiline && ( ( textHeight + lineSpacing ) * ( lineCount + 2 ) + lineSpacing ) > height ) {
14071416 // If the Text is higher than the FieldObject
14081417 continue FontSize;
14091418 }
1410- lastWordInLine = key ;
14111419 }
14121420
14131421 var line = '' ;
@@ -1461,7 +1469,6 @@ AcroForm.internal.calculateX = function (formObject, text, font, maxFontSize) {
14611469} ;
14621470
14631471AcroForm . internal . calculateAppearanceStream = function ( formObject ) {
1464- // todo: Take Height into consideration
14651472 if ( formObject . appearanceStreamContent ) {
14661473 // If appearanceStream is already set, use it
14671474 return formObject . appearanceStreamContent ;
0 commit comments