0

I have a single page form that has 2 fields (Named Record). My goal is to expand this to 50 pages each with 2 fields that add 1 to the previous field number. IE, page 1 has record 1 and 2, page 2 has records 3 and 4 and so on up to page 50 having record 99 and 100. Everything on each page is exactly the same except the Record number. Is there a way to easily do this short of saving the single page, copying it and joining it 50 times then editing each field with a static number? I would like to put the first number into the first page, first field and have it auto-populate the other 99 fields. I am using Foxit PDF Editor Pro 12 but I assume it would be the same solution if I were using Acrobat.

Here is a link to the single page pdf I am trying to work with

EJM
  • 1

2 Answers2

0

If your numbering can be slightly different, it is easier, using Templates:

  1. Create the single page with both areas and fields. For the fields, I suggest to use the pattern f1.<fieldname> for the upper part, and f2.<fieldname> for the lower part. With this, you have already grouped the fields for each part.

  2. Turn this page into a Template and hide it (here, let it call tp.

  3. From the Console spawn this template half of the number of records you need, using

    var myTP = this.getTemplate("tp") ;
    var recpag = 50 ; // for the example 
    for (var i = 0 ; i < recpag ; 1++) {
        myTP.spawn(this.numPages, true, false ; 
    }
    

This will create 50 pages, where the upper fields follow the pattern Pxtp.f1.<fieldname> (where x is the page number). With that, you have unique fields.

If using the f1, f2 field names are not acceptable, you would create two templates, one with the upper block, and one with the lower block. To spawn, you'd first spawn the first template, with the third argument set to false, and then the second template with the third argument set to true (which would overlay the template onto the already existing page). For this, I'd recommend to have a look at the Acrobat JavaScript documentation.

Another approach would be creating the Template page without fields, spawn the according number of times, and then programmatically add the fields using the addField() Doc Object method; also see documentation.

Max Wyss
  • 1,683
-1

You need to take into account that PDF numbering starts 0 even the first page internally is referenced as base page zer0. So copy or merge PDF file(s) with fields is often a problem of poor numbers. In this case I numbered as record 0001 and 0002 and thus for 5 duplicated pages with fields we get #0 - #4 of each. The upshot is that whatever you put in record 1 will be cloned / copied exactly into top box of all pages, and same with bottom field.

enter image description here

Thus it becomes a more challenging task to duplicate all pages first then add fresh numeric fields to the now existing pages.

I am trying to address that simply, but for cloning the base page (Page 0) there are things to improve so if you halve the image and insert its reference twice plus remove all other redundant contents, the file will become significantly smaller.

The 5 page sample above is only 59,519 bytes though should be say 60 KB, whereas the source file was 235,494 bytes so 5 times as many pages for roughly 25% the size in bytes.

So temporary "full answer" is use over stamping of that area with incremental numbers. With a tool like cpdf, which can first add 50 page references to Page 0 which is made from 2 image references (or simply remove the fields from your template then clone pages).

K J
  • 1,248