XFA Form - Print Button | Community
Skip to main content
Level 1
February 4, 2026
Question

XFA Form - Print Button

  • February 4, 2026
  • 2 replies
  • 35 views

Hello,

 

I have been working on a XFA Form I created using AEM Form Designer. The form is used to intake customers who come to our service center for computer repairs. It has 2 pages the first is for the customer and the second is for the technician and has the computer info, ticket number, and customer info that was inputted on first page. The customer can drop off up to 5 different computers per form. 

I originally built out a script using AcroForms which allowed me to print the customer page once and the technician page for the # of computers inputted on the form based on serial numbers with their respective fields being Serial1 through Serial5. The code below added the last page multiple times depending on if their were multiple serial numbers on the intake forms. This worked as intended without issues. Below is the code I used. 

 

var printArray = [[0,0]];

for(var i = 1; i<=5; i++){

    if((Serial + i).value != “”){

        printArray.push([1,1]);

    }

}

var pp = this.getPrintParams();

pp.printRange = printArray;

this.print(pp);


Trying to replicate this using XFA-forms I could only find info on the ‘Print Button’ which uses the built in print method. Which almost does what I want but it makes multiple print dialogue boxes where as the first method in AcroForms requires little user input and only has one dialogue popup.  See below for my code for XFA-Form version:

// Customer copy showing print dialogue box

xfa.host.print(1,”0”,”0”,0,0,0,0,0);

// Technician copy showing print dialogue box

xfa.host.print(1,”1”,”1”,0,0,0,0,0)

 

Is it even possible to do this using XFA Forms? Is there a way to use the script I made in AcroForms in XFA-forms? For instance a custom script that invokes the method I used in AcroForms.

 

 

2 replies

Adobe Employee
February 10, 2026

Hi ​@TGuigz,

In AcroForms, it is possible to control printing very precisely using Acrobat’s document-level JavaScript APIs. By building a custom print range and invoking a single this.print() call with getPrintParams(), the form can print the customer page once and automatically repeat the technician page based on how many serial numbers are entered, all within a single print dialog.

XFA forms, however, handle printing differently. The built-in XFA method (xfa.host.print) is designed to print one range per call and always displays a print dialog for each invocation. Because of this, calling xfa.host.print multiple times results in multiple print dialogs, which limits automation when printing variable numbers of pages.

That said, this limitation can be worked around. While XFA itself does not expose advanced print range controls, the PDF can still leverage Acrobat’s document-level JavaScript. By reading the XFA field values (such as populated serial numbers) and constructing a print range array dynamically, the form can call Acrobat’s this.getPrintParams() and this.print() methods once. This approach produces the same result as the original AcroForms solution: a single print dialog and automatic duplication of the technician page based on the number of devices entered.

In summary:

  • XFA’s native print method cannot combine multiple print jobs into one dialog.

  • Acrobat document-level JavaScript can be used with XFA forms to achieve the same single-dialog, multi-page printing behavior as AcroForms.

  • The solution is supported in Acrobat and does not require user interaction beyond the initial print confirmation.

Thanks
Pranay

Adobe Employee
February 16, 2026

Hi ​@TGuigz,

Please let me know if the above suggestion resolved the issue.
 

radzmar
Level 10
February 19, 2026

The Acrobat solution will also work in XFA forms. You only have to change the script a little bit. 
The word “this” always has to be replaced with “event.target” and the reference to the field “Serial…” needs to be XFA conform as well. Assuming the forms hierarchy looks like this.

form1
    masterpages
        …
    Page1
        Serial1
        Serial2
        Serial3
        Serial4
        Serial5
        …


 

var printArray = [[0,0]];
for (var i = 1; i <= 5; i ++) {
if (!Page1.resolveNode("Serial" + i).isNull) {
printArray.push([1,1]);
}
}

var pp = event.target.getPrintParams();
pp.printRange = printArray;
event.target.print(pp);


For every filled serial field a new copy of the second page is added.