merge PDF files programmatically using VBA

Community Beginner ,
Oct 15, 2018

Copy link to clipboard

Copied

Hi,

i hope someone can help.

I have PDF files that i want to merge, the problem is that the fillable Fields are all same have.

After merging all fillable Fileds have the same values

Kind regards

Adobe Community Professional
Correct answer by Karl Heinz Kremer | Adobe Community Professional

I don't have anything for duplicating text fields, but what you do is to loop over all fields and process every text field you find, and then basically just go down the list of field properties that apply to text fields and apply them to your newly created field. You can find the list of properties in the SDK documentation:

Acrobat DC SDK Documentation - Field Properties

Keep in mind that not all properties apply to text fields. If you want to look at something similar, I wrote a blog post a while ago about converting radio buttons to checkbox groups: Convert Radio Button Groups to Checkbox Groups in PDF Forms - KHKonsulting LLC

TOPICS
Acrobat SDK and JavaScript

Views

1.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

merge PDF files programmatically using VBA

Community Beginner ,
Oct 15, 2018

Copy link to clipboard

Copied

Hi,

i hope someone can help.

I have PDF files that i want to merge, the problem is that the fillable Fields are all same have.

After merging all fillable Fileds have the same values

Kind regards

Adobe Community Professional
Correct answer by Karl Heinz Kremer | Adobe Community Professional

I don't have anything for duplicating text fields, but what you do is to loop over all fields and process every text field you find, and then basically just go down the list of field properties that apply to text fields and apply them to your newly created field. You can find the list of properties in the SDK documentation:

Acrobat DC SDK Documentation - Field Properties

Keep in mind that not all properties apply to text fields. If you want to look at something similar, I wrote a blog post a while ago about converting radio buttons to checkbox groups: Convert Radio Button Groups to Checkbox Groups in PDF Forms - KHKonsulting LLC

TOPICS
Acrobat SDK and JavaScript

Views

1.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 15, 2018 0
Most Valuable Participant ,
Oct 15, 2018

Copy link to clipboard

Copied

You need to change all the field names, or flatten each subfile so it isn't fillable, or use a portfolio (not with VBA).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 15, 2018 1
Adobe Community Professional ,
Oct 15, 2018

Copy link to clipboard

Copied

Changing the fields names are not simple when there are calculations in the form.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 15, 2018 1
Community Beginner ,
Oct 16, 2018

Copy link to clipboard

Copied

thank you for your Quick response.

There are no calculation in the form !

Kind regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2018 0
Adobe Community Professional ,
Oct 16, 2018

Copy link to clipboard

Copied

I don't have anything for duplicating text fields, but what you do is to loop over all fields and process every text field you find, and then basically just go down the list of field properties that apply to text fields and apply them to your newly created field. You can find the list of properties in the SDK documentation:

Acrobat DC SDK Documentation - Field Properties

Keep in mind that not all properties apply to text fields. If you want to look at something similar, I wrote a blog post a while ago about converting radio buttons to checkbox groups: Convert Radio Button Groups to Checkbox Groups in PDF Forms - KHKonsulting LLC

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2018 0
Adobe Community Professional ,
Oct 15, 2018

Copy link to clipboard

Copied

What you see is actually a feature of PDF forms: Fields that have the same name will automatically have the same content. This allows you to add e,g. a name field on the first page, and then copy that name on every other page of your form. The user only needs to fill in the name once, and it will show up on every page of the for.

In your case, that feature gets into the way of what you want to do. There are two ways around this: You can either rename the fields in your forms, or make sure that once the page(s) are added to your merged document, the form fields are no longer interactive fields, but get "flattened" to static PDF content.

Which one of these methods is appropriate for you depends on what you want to do with the merged document. If you need to still be able to edit these fields, then you have to make sure that the fields remain interactive fields.

You cannot rename fields within the VBA interface (or JavaScript for that matter). You may be able to recreate fields with  similar settings, but there are a few things that you cannot recreate (e.g. scripts that are associated with the fields).

Another option would be to create a bigger solution that handles the merging by having a document that contains template pages. You would then spawn one or more pages in your "merged" document, and the spawning process can automatically rename these fields for you, so that you don't end up with any duplicates. This step will however only add blank pages to your document, so your VBA solution then needs to be able to copy information from the source document to the merged document, taking the now modified target field names into account. This is not as straight forward as simply merging the files, but will give you a merged document that uses unique field names for all pages.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 15, 2018 2
Community Beginner ,
Oct 16, 2018

Copy link to clipboard

Copied

thank you for your Quick response.

Do you have some Codesnippet that i can you for this problem ??

Kind regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 16, 2018 0