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

Help with Smart Form - Overlapping

New Here ,
Mar 27, 2023 Mar 27, 2023

Hi All, Thank you in advance for your replies.

I have created a form in Adobe Acrobat DC and put a Javascript in a button that generates new text fields below each other as you press the button, I am facing an issue with the text filed reaching the end of the page and not going in to the second page directly. Can someone help please???

TOPICS
Create PDFs , How to , JavaScript , PDF forms
1.6K
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
Community Expert ,
Mar 27, 2023 Mar 27, 2023

Hi, @Alfonso222825050e74 ,

 

Please share an example of the PDF or the script that you're using.

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
New Here ,
Mar 27, 2023 Mar 27, 2023
LATEST
 
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
LEGEND ,
Mar 27, 2023 Mar 27, 2023

Does your code check whether there is space, create a new page, and start adding fields to the new page? Or do you hope that it happens automatically?

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
New Here ,
Mar 27, 2023 Mar 27, 2023
var x = 50; var y = 450; var width = 400; var height = 200; var startY = 380; // the starting y-coordinate var fieldHeight = 200; // the height of each field function isOverlapping(newRect, existingRect) {   return (     newRect[0] < existingRect[2] &&    newRect[2] > existingRect[0] &&    newRect[1] > existingRect[3] &&    newRect[3] < existingRect[1]   ); } function findAvailableYPosition(newX, width, height) {   var newY = 0;    for (var i = 0; i < this.numFields; i++) {     var existingField = this.getField(this.getNthFieldName(i));     var existingRect = existingField.rect;      var newRect = [newX, newY + height, newX + width, newY];      while (isOverlapping(newRect, existingRect)) {       newY += height; // Move the new field down by its height       newRect = [newX, newY + height, newX + width, newY];     }   }    return newY; } function createNewPageIfNeeded(newY) {   var currentPage = this.pageNum;   var currentPageHeight = this.getPageBox("Crop", currentPage)[1]; console.println("page height:"+currentPageHeight+"y"+newY);   if (newY >= currentPageHeight) {    var a = this.getTemplate("TET"); a.spawn(); return 1;   } } var selectedChoice = this.getField("Group11").value; var selectedChoice2 = this.getField("Group33").value; var selectedChoice1 = this.getField("Group22").value; if(selectedChoice == "Choice2"){ app.alert("This is for new customer");} else if(selectedChoice1 == "Choice2"){ app.alert("This is for cap TYPE");} else if(selectedChoice2 == "Choice4"){ app.alert("KYC should be Yes");} var dropdown = this.getField("Dropdown18"); console.println("droplist:"+dropdown.value) // Show a "yes" or "no" alert var response = app.alert("Do you want to continue?", 2, 2); // If the user clicks "yes", log a message to the console if (response == 4) { console.println("User clicked 'Yes'"); for (var i = 0; i < dropdown.value; i++) { // Create a unique name for the field var name11 = "field" + i; var pagenum = 0; var y = startY - (i * fieldHeight); // calculate the y-coordinate for the current field // Check if the new Y coordinate is beyond the current page height if(createNewPageIfNeeded(y)){ console.println("New page added") pagenum+=1; } console.println("page height:"+y); // Create the field at the specified coordinates //this.addField(name11, "text", 0, [x, y, x + width, y + height]); this.addField(name11,"text", pagenum, [50, y, width, y + fieldHeight]); // add the field at the calculated coordinates var newX = 100; // Set the new X coordinate (in points) // Get the current field rectangle [left, top, right, bottom]   //var currentRect = name11.rect;   // Calculate the width and height of the field   //var width = currentRect[2] - currentRect[0];   //var height = currentRect[1] - currentRect[3];   // Find an available Y position that does not overlap with existing fields   var newY = findAvailableYPosition(newX, width, height);   // Set the new rectangle for the field   name11.rect = [newX, newY + height, newX + width, newY]; // Increment the y-coordinate for the next field y += fieldHeight - 10; } } // If the user clicks "no", log a message to the console else if (response == 2) { console.println("User clicked 'No'"); var field = this.getField("Dropdown18"); field.reset(); } console.println("Selected choice is: " + selectedChoice);
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
New Here ,
Mar 27, 2023 Mar 27, 2023

Hi Guys Thank you very much for this, Please find below code used in the drop down.

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