Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add Rows to textfields with javascript

New Here ,
May 23, 2023 May 23, 2023

Hello guys! I´m new to adobe acrobat and java scripting but i was able to allready get there where i want to be. I created this script:

 

var myRows = new Array();
myRows[0] = "Row1.Column1";
myRows[1] = "Row1.Column2";
myRows[2] = "Row1.Column3";
myRows[3] = "Row1.Column4";
myRows[4] = "Row1.Column5";
myRows[5] = "Row1.Column6";

 

var coordinates = [
{ left: 56.6181, right: 107.642, top: 483.585, bottom: 472.246 },
{ left: 109.615, right: 160.639, top: 483.585, bottom: 472.246 },
{ left: 233.327, right: 284.35, top: 483.585, bottom: 472.246 },
{ left: 285.887, right: 336.911, top: 483.585, bottom: 472.246 },
{ left: 409.164, right: 476.139, top: 483.585, bottom: 472.246 },
{ left: 513.662, right: 564.686, top: 483.585, bottom: 472.246 },
];

// Überprüfen, ob die Verschiebung bereits stattgefunden hat
if (typeof this.numRowsAdded === 'undefined') {
this.numRowsAdded = 0;
} else {
this.numRowsAdded += myRows.length;
}

var verticalGap = coordinates[0].top - coordinates[1].top; // Vertikaler Abstand zwischen den Textfeldern

for (var i = 0; i < myRows.length; i++) {
var afields = [
coordinates[i].left,
coordinates[i].top - (this.numRowsAdded * verticalGap) - (i * verticalGap),
coordinates[i].right,
coordinates[i].bottom - (this.numRowsAdded * verticalGap) - (i * verticalGap)
];
this.addField(myRows[i], "text", 0, afields);
}

 

It creates six text boxes in a PDF document in the right place after I press the button I added the script to. Now I want it to be like this:

Every time I press the button, the six text boxes should appear below the previous boxes with a spacing of 15.039pt.

The previous fields should still stay where they are. The left/right coordinates stay the same, but 'top' and 'button' need to be reduced by 15.039pt.

Is there any way to make the fields appear 15.039p below the existing fields?

 

Thanks in advance !

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms
265
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation