Read XFA form fields and fill data using Aspose.PDF for .NET

Hi Jose,


Thanks for contacting support. I am able to notice the error message which is occurring when opening the fw5±+copia.pdf file. I am afraid I could not replicate this issue over my end. Can you please share the code snippet which you are using so that we can test the scenario at our end. We are sorry for this inconvenience.

Hi Codewarrior,

The "fw5 - copia.pdf" pdf file is the original pdf (without form field filled out). This file has no problem and i attached you because with it you can start your test trying to fill out these fields. So, instead opening "fw5 - copia.pdf" try to open "fw5.pdf" attached in previous post.

The problem is with "fw5.pdf" file (pdf form filled out). This pdf has filled the state ("provincia") and city ("municipi") and when you open the PDF, these errors happend.

I followed your instructions to fill out the form and it works, but only with these fields when you open the result pdf, it crashes (althought fields were fillout well finally).

Codesnippet:

public const string PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.ADRECA_ESTR.LLISTA_PROVINCIES";

public const string PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.ADRECA_ESTR.LLISTA_MUNICIPIS";

FileStream fs = new FileStream(@"C:\fw5.pdf", FileMode.Open, FileAccess.ReadWrite);
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs);

// Fill the state
pdfDocument.Form.XFA[PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES] = "Barcelona";

// Fill the city
pdfDocument.Form.XFA[PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS] = "Alella";

pdfDocument.Save();
fs.Close();

PD.- When you open the result PDF, please choose "Actuo en nom de la persona sollicitant (presentador)"

Thanks in advance.

Hi Jose,

Thanks for sharing the details.

I have again tested the scenario where I have used Aspose.Pdf for .NET 7.1.0 to fill the source
fw5 - copia.pdf file using the code snippet which you have shared and as per my observations, when I have tried viewing the document, I am unable to notice any issue. Also please note that the data is not being populated/inserted in source PDF form. I have tested the scenario in VisualStudio 2010 project running over Windows 7 X64 Enterprise, and I have specified the target platform of application as .NET Framework 3.5. Can you please share some details regarding your working environment. We are sorry for this inconvenience.

For your reference, I have also attached the resultant PDF that I have generated.

[C#]

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

FileStream fs = new
FileStream(@“d:\pdftest\fw5_Filled.pdf”,
FileMode.Open, FileAccess.ReadWrite);

Aspose.Pdf.Document
pdfDocument = new Aspose.Pdf.Document(fs);

// Fill the state

pdfDocument.Form.XFA[“PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES”]
= “Barcelona”;

// Fill the city

pdfDocument.Form.XFA[“PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS”]
= “Alella”;

pdfDocument.Save();

fs.Close();

Hi Nayyerv,

I just opened your result pdf [fw5_Filled.pdf] and form fields are empty.

My working environment is:

VisualStudio 2008 project running over Windows 7 X64 Enterprise.

I'm using Aspose.Pdf v7.1.0 (Framework 3.5)

PDF opened with Adobe Reader v10.1.3

I attach you the javascript message error capture.

Also, i tried to open with an older adobe reader version (for example v9.1) and i obtain the same error messages.

Hi Nayyer, any news about this issue?

Hi Jose,

Thanks for sharing the details.

I have been able to notice the JavaScript error message when I have tried viewing fw5.pdf which you have shared at
398334. But as I have shared in my earlier post, I an unable to replicate this issue when I have tried filling the data inside PDF form. As per my understanding, until the data is populated in PROVINCIES and MUNICIPIS fields, the error message might not appear. Nevertheless, we are working on investigating the issue why data is not appearing in resultant PDF.

For testing purposes, I have used VisualStudio 2010 project running over Windows 7 X64 Enterprise and I have specified .NET Framework 3.5 as target platform for my application.

We are sorry for this inconvenience.

Hi again Hi Nayyer,

I have a new issue. In PDF you can fill out the data of two persons (name, surname, address, etc...)

Person 1 (sol-licitant)

Person 2 (presentador) - OPTIONAL

The scenary is this:

I want fillout the form fields of both of them. To do this, i fill out the form fields by code (using codesnippet posted below). When open the result PDF i choose "Actuo en nom de la persona sol-licitant (presentador)" but only data of Person 2 (presentador) is filled and Person 1 (sol-licitant) data is empty.

If i do the same but only filling out the Person 1 form fields and choosing "Soc la persona interessada (sol-licitant)" when i open the PDF, the form fields data of Person 1 is filled.

What could be the problem on this issue?

Codesnippet in C#:

// Person 1 (SOL-LICITANT)
public const string SOLLICITANT_NOM = @"GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.TXT_NOM";
public const string SOLLICITANT_COGNOM1 = @"GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.TXT_COGNOM1";
public const string SOLLICITANT_COGNOM2 = @"GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.TXT_COGNOM2";

// Person 2 (PRESENTADOR)
public const string PRESENTADOR_NOM = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.TXT_NOM";
public const string PRESENTADOR_COGNOM1 = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.TXT_COGNOM1";
public const string PRESENTADOR_COGNOM2 = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.TXT_COGNOM2";

...

FileStream fs = new FileStream("C:\\fw5.pdf", FileMode.Open, FileAccess.ReadWrite);
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fs);

// Fill out the Person 1 (Sol-licitant) form fields
pdfDocument.Form.XFA[SOLLICITANT_NOM] = "ALBERTO";
pdfDocument.Form.XFA[SOLLICITANT_COGNOM] = "GARCÍA";
pdfDocument.Form.XFA[SOLLICITANT_COGNOM2] = "SÁNCHEZ";

// Fill out the Person 2 (Presentador) form fields
pdfDocument.Form.XFA[PRESENTADOR_NOM] = "PETER";
pdfDocument.Form.XFA[PRESENTADOR_COGNOM] = "SMITH";
pdfDocument.Form.XFA[PRESENTADOR_COGNOM2] = "BOILE";

pdfDocument.Save();
fs.Close();

Hi Jose,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 7.1.0 while using the code snippet shared above and as per my observations, when I have selected ‘Actuo en nom de la persona sol·licitant (presentador)’ radio button, I am able to see Person 2 (Presentador) information. Whereas when I have selected ‘Sóc la persona interessada (sol·licitant)’ radio button on resultant PDF, I am able to see Person 1 (Sol-licitant) information. Can you please try viewing the resultant PDF that I have generated and in case I am not able to understand this issue properly, please share further details.

We apologize for your inconvenience,.

Hi again,

Note that in the codesnippet shared on my last post i'm trying fill out the data of both persons (presentador and sol·licitant).

Case 1: If you selected 'Sóc la persona interessada (sol·licitant)' radio button.

The form has 3 pages. Page 1 is the sol·licitant data.

The form shows only the sol·licitant form field's. This is right because the form shows sol·licitant field's with data (filled out) and you choosed this option in form.

Case 2: If you selected 'Actuo en nom de la persona sol·licitant (presentador)' radio button.

The form has 4 pages. Page 1 is the presentador data AND Page 2 is the sol·licitant data.

The form shows the presentador field's with data (filled out) AND the sol·licitant field's without data (not filled out). This is the problem, because on my codesnippet i want fillout both of them (sol·licitant and presentador) and only can see filled out the presentador field's.

RESUME:

I want fill out the fields of both persons (sol·licitant and presentador). So, when open the PDF i must select 'Actuo en nom de la persona sol·licitant (presentador)'. After this, i only can see well filled out the presentador field's (page 1) but not the sol·licitant field's (page 2) because they are empty.

Hi Jose,

Thanks for sharing the details.
<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

I
have again tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as <span style=“font-family:“Arial”,“sans-serif””>PDFNEWNET-34043. We
will investigate this issue in details and will keep you updated on the status
of a correction.

<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>We
apologize for your inconvenience.

Thank you Nayyer.

Please, add too in your issue tracking system the JavaScrip error issue shared by me few posts ago. As you wrote, could be because combo data was not pupulated yet when the form field was filled out. Thist only occurs in combo fields with relational data population like PROVINCIA' (State) and 'MUNICIPI' (City).

newinformatics:
Please, add too in your issue tracking system the JavaScrip error issue shared by me few posts ago. As you wrote, could be because combo data was not pupulated yet when the form field was filled out. Thist only occurs in combo fields with relational data population like PROVINCIA’ (State) and ‘MUNICIPI’ (City).

Hi Jose,

I have again tested the scenario while using the code snippet shared over 398616 link and I have managed to reproduce the same problem. When trying to view the resultant PDF in Adobe Reader 10.1.3, I am also getting the same error messages. In order to get this issue resolved, I have separately logged it as PDFNEWNET-34044 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

PS, In my reply over
398692 here, I did not provide the complete field name, so the information was not being populated in resultant PDF.

No problem Nayyer, I'm patient :) .Thanks for your work.

Hi Nayyer, please help me with this:

On this PDF form there are two kind of people: Sol·licitant and Presentador.

In both of them, there are two kind too:

- Sol·licitant as fisic person - Sol·licitant as legal person (Enterprise)

- Presentador as fisic person - Presentador as legal person (Enterprise)

In this case i need fill out Sol·licitant form fields as legal person (Enterprise). So, i need select 'Persona jurídica' on radiobutton.

Scenario:

Open the PDF and select the radiobutton 'Sóc la persona interessada (sol·licitant)'.

On Sol·licitant form fields, the first field is a RadioButton type. The options are: 'Persona física' and 'Persona jurídica'. Is selected 'Persona física' by default but i need select 'Persona jurídica' because i want fill out the field 'Raó social'.

My Tests:

I'm not able to select by default 'Persona jurídica' in radiobutton. The codesnippet i used to filling out the 'Raó social' is:

pdfDocument.Form.XFA[GTIS_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.PERSONA_JURIDICA.DADES_IDENTIFICACIO_EMPRESA.CONTACTE.TXT_NOM_EMPRESA] = 'MYENTERPRISE & CO'. I think the radiobutton fields could be:

GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.FISICA

GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.FISICA

GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.TIPUS_USUARI

I tried assign values 'S' or 'N' but not works. By default always 'Persona física' is selected and when i select manually 'Persona jurídica', the 'Raó social' field is empty.

Can you post me a codesnippet and result filled pdf for this case?. I tried but i'm not be able do it.

this could be a new issue or is there an error on my procediment?.

Thanks a lot.

Sorry for my last post. It woks!. Please do not notice my last post.

Hi Jose,

I am glad to hear that your problem is resolved or you have figured out the solution. Please do let me know, if I can be of any further assistance.

Thanks for contacting support.

Hi, Any news about this issues?.

PDFNEWNET-34043

PDFNEWNET-34044

Thanks

Hi,


Thanks for your patience.

Our development team is working hard
on resolving this issue but I am afraid this problem is not yet
completely fixed. Nevertheless, I have requested the development team to share
any possible ETA. As soon as I have some updates regarding its resolution, I
would be more than happy to update you with the status of correction. Please be
patient and spare us little time.

We are sorry for this delay and inconvenience.

Hi,


Thanks for your patience.

We have further investigated the issue PDFNEWNET-34044 and have found the reasons of problem. In your source form, provinces and cities have specific codes:

//provincies:
var arrProvinciesEsp = new Array([“Álava”,“01”,“arrAlaba”], [“Albacete”,“02”,“arrAlbacete”], [“Alicante/Alacant”,“03”,“arrAlacant”],[“Almería”,“04”,“arrAlmeria”], [“Asturias”,“33”,“arrAsturies”], [“Ávila”,“05”,“arrAvila”], [“Badajoz”,“06”,“arrBadajoz”], [“Balears (Illes)”,“07”,“arrBalearsIlles”], [“Barcelona”,“08”,“arrBarcelona”], [“Burgos”,“09”,“arrBurgos”], [“Cáceres”,“10”,“arrCaceres”],

//cities

var arrBarcelona = new Array([“Abrera”,“08001”],[“Aguilar de Segarra”,“08002”],[“Aiguafreda”,“08014”],[“Alella”,“08003”],[“Alpens”,“08004”],[“Ametlla del Vallès (L’)”,“08005”],[“Arenys de Mar”,“08006”],[“Arenys de Munt”,“08007”],[“Argençola”,“08008”],[“Argentona”,“08009”],

In order to resolve the problem, fill province and city, province/city code should be used instead of name. Please take a look over following code snippet.

[C#]

FileStream fs = new FileStream("d:/pdftest/fw5_Source

  • UnFilled (1).pdf", FileMode.Open,
    FileAccess.ReadWrite);<o:p></o:p>

Document pdfDocument = new Document(fs);

string PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.ADRECA_ESTR.LLISTA_PROVINCIES";

string PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS = @"GSIT_PICA_GRO_SOLLICITUD.presentador.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.ADRECA_ESTR.LLISTA_MUNICIPIS";

//for requeridor

string PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES1 = @"GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.ADRECA_ESTR.LLISTA_PROVINCIES";

string PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS1 = @"GSIT_PICA_GRO_SOLLICITUD.requeridor.PERSONA_FISICA_O_JURIDICA.PERSONA_FISICA.DADES_IDENTIFICACIO_PARTICULAR.CONTACTE.ADRECA_ESTR.LLISTA_MUNICIPIS";

// Fill the state

pdfDocument.Form.XFA[PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES] = "08";//"Barcelona";

// Fill the city

pdfDocument.Form.XFA[PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS] = "08003";// "Alella";

// Fill the state

pdfDocument.Form.XFA[PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_PROVINCIES1] = "08";//"Barcelona";

// Fill the city

pdfDocument.Form.XFA[PRESENTADOR_FISICA_CONTACTE_ADRECA_LLISTA_MUNICIPIS1] = "08003";// "Alella";

pdfDocument.Save();

fs.Close();