XML-PDF Automatic Form Population from Excel Source - xfdf/ns1 Issue

Pettie

New Member
Joined
Jan 18, 2017
Messages
3
Hi guys,

Thanks for taking the time to look at this question for me.
The Situation
I'm trying to automatically populate multiple .pdf's from my Excel source data.
So far I've been successful with all of these forms, I have been using Foxit Reader to export the .xml data from the form and then mapping it in Excel.
The Problem
I was finding some fields wouldn't populate when I imported them back into the .pdf.
It appears to be caused by the embedded properties of the .xml changing from xfdf to ns1.
Example 1
When I open the .xml file which doesn't import successfully using Notepad++ I can see the below:
<!--?xml <font color="#FF0000"-->version="1.0" encoding="UTF-8" standalone="yes"?>
<fields <font="" color="#FF0000">xmlns:ns1="http://ns.adobe.com/xfdf-transition/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<instrument>Guitar</instrument></fields>​
<name>Joe Bloggs</name>
<nameofsociety <font="" color="#FF0000">ns1:original="Name of society">America</nameofsociety>
<nationality>British</nationality>

ns1:original="Place of birth">United Kingdom</placeofbirth>


The blue is the text that will be imported (i.e. the text which auto-populates from the Excel source).
The "Nameofsociety" & "Placeofbirth" fields are the only fields which currently don't auto-populate. However, if I change the "ns1" to "xfdf" in the .xml it works.
Example 2
Exported from the .pdf
<textfield17 <font="" color="#FF0000">xfdf:original="Text Field 17">Email</textfield17>​
<textfield18 <font="" color="#FF0000">xfdf:original="Text Field 18">Website</textfield18>
<textfield19 <font="" color="#FF0000">xfdf:original="Text Field 19">DoB</textfield19>

Imported into Excel, populated and then exported back into a .xml

<textfield17 <font="" color="#FF0000">ns1:original="Text Field 17">Email</textfield17>​
<textfield18 <font="" color="#FF0000">ns1:original="Text Field 18">Website</textfield18>
<textfield19 <font="" color="#FF0000">ns1:original="Text Field 19">DoB</textfield19>
So like in Example 1, it has changed the xfdf field to ns1 and now those fields don't populate. However, if I Find & Replace the ns1 to xfdf, it works again.
This workaround works but obviously a solution would be preferable!


I'm unsure why the .xml contains only xfdf when exported from the .pdf form but when I import into Excel, populate and then export back out it has changed some of the fields to ns1 which therefore causes that field to not work.
The Solution
I need the following to happen:

Either
A) Prevent Excel from converting the xfdf fields to ns1.
OR
B) Some automatic way to change the ns1 back to xfdf - I'm looking at using Macros in Excel, VBA (although I currently only have very limited knowledge with VBA) and Autohotkey or some kind of combination of the above to enact this solution.

Sundry
I am happy to provide a copy of the .pdf forms if people would so require, as I can't attach files quite yet please just let me know and I'll paste a link in.

I am also keen to learn more about why this is happening and what I can improve to prevent it from happening in future, any advice is very welcomed and appreciated!

Summary
I am exporting a .xml from a .pdf.
I then map the schema myself in Excel and populate the relevant fields.
I then export from Excel a new .xml file.
I then import the new .xml back into the original .pdf which results in the form being fully filled in.

However, on some of the forms, it converts the metadata from xfdf to ns1 and those fields stop working until they are changed back into xfdf.

Anything that I can do to prevent it from changing to ns1 or an automatic way of converting them back would be very helpful.

Thanks very much in advance for any and all the help provided!

Joe
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi all,

When I originally posted it had timed out and I've only just realised it had removed some of the wording I added so I've re-included my examples below.
Please disregard the above Example 1 & 2 and use these instead:

Example 1
When I open the .xml file which doesn't import successfully using Notepad++ I can see the below:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fields xmlns:ns1="http://ns.adobe.com/xfdf-transition/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[INDENT]<Instrument>Guitar</Instrument>[/INDENT]
[INDENT]<Name>Adam James Nutter</Name>[/INDENT]
          <Nameofsociety ns1:original="Name of society">Joe-NameofSociety</Nameofsociety>

The "Nameofsociety" field is the only field which currently doesn't auto-populate. However, if I change the "ns1" to "xfdf" in the .xml it works.

Example 2
Exported from the .pdf
Code:
<?xml version="1.0" encoding="UTF-8"?>
<fields xmlns:xfdf="http://ns.adobe.com/xfdf-transition/">[INDENT]<TextField17 xfdf:original="Text Field 17">Email</TextField17>[/INDENT]
[INDENT]<TextField18 xfdf:original="Text Field 18">Website</TextField18>[/INDENT]
[INDENT]<TextField19 xfdf:original="Text Field 19">DoB</TextField19>[/INDENT]
</fields>
Imported into Excel, populated and then exported back into a .xml
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fields xmlns:ns1="http://ns.adobe.com/xfdf-transition/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">[INDENT]<TextField17 ns1:original="Text Field 17">Email</TextField17>[/INDENT]
          <TextField18 ns1:original="Text Field 18">Website</TextField18>
          <TextField19 ns1:original="Text Field 19">DoB</TextField19>
</fields>
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top