PDF Fields

Hi,


I am creating a pdf from scratch and adding fields using Aspose.Pdf.Generator and Aspose.Pdf.Generator.FormField. The data in the fields will be entered in by the enduser. My problem is that I can not access the fields’ values after data is entered into the pdf. Below is my test code for creating the pdf and fields:
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Table table1 = new Aspose.Pdf.Generator.Table();
table1.ColumnWidths = “120 120 120”;
sec1.Paragraphs.Add(table1);


Aspose.Pdf.Generator.Row row1 = table1.Rows.Add();

Aspose.Pdf.Generator.Cell cell1 = row1.Cells.Add(“Name”);
cell1.Padding.Left = 30;
cell1.Paragraphs[0].ID = “cell1”;


Aspose.Pdf.Generator.Cell cell2 = row1.Cells.Add(“City”);
cell2.Padding.Left = 30;
cell2.Paragraphs[0].ID = “cell2”;

Aspose.Pdf.Generator.Cell cell3 = row1.Cells.Add(“State”);
cell3.Padding.Left = 30;
cell3.Paragraphs[0].ID = “cell3”;

Aspose.Pdf.Generator.FormField field = new Aspose.Pdf.Generator.FormField();
field.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Text;
field.IsBordered = true;
field.TextFontName = “Tahoma”;
field.TextFontSize = 8;
field.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
field.FieldName = “Name”;
field.FormWidth = 80;
field.FormHeight = 15;
field.ReferenceParagraphID = “cell1”;
field.Left = -20;
field.Top = 15;

Aspose.Pdf.Generator.FormField field2 = new Aspose.Pdf.Generator.FormField();
field2.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Text;
field2.IsBordered = true;
field2.TextFontName = “Tahoma”;
field2.TextFontSize = 8;
field2.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
field2.FieldName = “City”;
field2.FormWidth = 80;
field2.FormHeight = 15;
field2.ReferenceParagraphID = “cell2”;
field2.Left = -20;
field2.Top = 15;


Aspose.Pdf.Generator.FormField field3 = new Aspose.Pdf.Generator.FormField();
field3.FormFieldType = Aspose.Pdf.Generator.FormFieldType.Text;
field3.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
field3.IsBordered = true;
field3.TextFontName = “Tahoma”;
field3.TextFontSize = 8;
field3.FieldName = “State”;
field3.FormWidth = 80;
field3.FormHeight = 15;
field3.ReferenceParagraphID = “cell3”;
field3.Left = -20;
field3.Top = 15;

sec1.Paragraphs.Add(field);
sec1.Paragraphs.Add(field2);
sec1.Paragraphs.Add(field3);
pdf1.Save(fileName);

The code I used to try to access the data is below:
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(“fileName”);

foreach (Aspose.Pdf.Generator.FormField formField in pdfDocument.Form)
{
System.Console.WriteLine("Field Name : {0} ", formField.FieldName);
System.Console.WriteLine("Value : {0} ", formField.FieldValue);
}

Hi,


Thanks for using our products.

Aspose.Pdf.Generator provides the capability to create PDF documents from scratch. I am afraid it does not support the feature to manipulate existing PDF files. In order to get the form field values, you may either try using Aspose.Pdf.Facades namespace or use the new DOM API (Aspose.Pdf namespace). Nevertheless, when using following code snippet, I have observed that form field values are not being retrieved. For the sake of correction, I have logged this
issue as
PDFNEWNET-35909 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.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/FormWithData.pdf");

//get values from all fields

foreach (Field formField in pdfDocument.Form)

{

Console.WriteLine("Field Name : {0} ", formField.FullName);

Console.WriteLine("Value : {0} ", formField.Value);

}

Thank you for your response and further looking in to the problem… Yeah, I had tried to retrieve the values the way you suggested as well, but had no luck as well. Sorry, I should have mentioned that in my original message. I look forward to your update.

Hi,


Now that we have been able to notice this issue, the development team will look into the details of this problem and we will keep you posted with our findings. Please note that as normal rule of practice, the issues logged under normal support forum are resolved in first come first serve basis except for the Enterprise and Priority Support issues which have high precedence in terms of resolution.

Your patience and comprehension and understanding is greatly appreciated in this regard.

Good morning! Just thought I would check to see if there are any updates. I realize there were other problems ahead of this one, but since it has been a week since I originally posted the question, I thought I would check to see if there are any new updates or if you happen to have an estimated time of when someone would be able to assist with this.

Hi there,


Thanks for your inquiry. I’m afraid your reported issue is still pending for investigation in the queue with other priority tasks. We will update you via this forum thread as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,

Hi,


It has been almost a month since I posted this question. Can you please provide a status update? We are also experiencing problems reading the values from a pdf form that was created via Adobe Pro. When using the following code, the pdfDocument.Form.Fields property doesn’t include the textbox fields in the Fields list, just the checkbox fields:
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(pdfFileName);

foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form)
{
if (formField.Value != null)
{
System.Console.WriteLine("Field Name : {0} ", formField.Name);
System.Console.WriteLine("Value : {0} ", formField.Value);
}
}

Hi there,


Thanks for your inquiry. I’m afraid your reported issue is still not resolved. Issue has been investigated and development team is working over for the fix. However, we’ve requested our team to share an ETA at their earliest. As soon as we get a feedback, we will update you via this forum thread.

heatherjoanne44:
We are also experiencing problems reading the values from a pdf form that was created via Adobe Pro.
Moreover, can you please share your sample document here? So we will investigate it and will provide you more information.

Thanks for your patience and cooperation.

Best Regards,

Hi, I was able to read the values from the pdf form that was created via Adobe Pro. I neglected to include the Skywalker.AsposeTotalLicense asposeTotalLicense = new Skywalker.AsposeTotalLicense() when attempting to retrieve the values, and therefore, it was only retrieving the first 4 checkbox fields. I am now able to retrieve the values from all fields with the exception of the signature field. When researching this, I found a way to retrieve the signature name by using the following code


Aspose.Pdf.Facades.PdfFileSignature pdfSignature = new Aspose.Pdf.Facades.PdfFileSignature(pdfDocument);

string signature = pdfSignature.GetSignerName(“CustomerSignature”);

However, I couldn’t find any forums related to retrieving the image from the signature field. Also, I tried to retrieve the image by using System.IO.Stream signature= pdfSignature.SignatureAppearanceStream; but pdfSignature.SignatureAppearanceStream is null.

Is there a way I can retrieve the image from the signature field?

Thanks so much!

Hi there,


We are sorry for the delayed response. We are looking into the issue and will get back to you soon.

Best Regards,

Hi there,


Thanks for patience. I’m afraid, we’ve also noticed the issue in extracting signature image from signature field. So we’ve logged an investigation ticket as PDFNEWNET-36044 for further investigation and resolution. As soon as the issue resolved we will notify you via this forum thread.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-35909) have been fixed in Aspose.Pdf for .NET 8.7.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi, I have downloaded the latest release, and I’m still unable to retrieve the image from the signature field in the pdf using the following code:

System.IO.Stream signature= pdfSignature.SignatureAppearanceStream. The SignatureAppearanceStream property is still null. Is there a new way to retrieve the image from the signature field?

Also, I’m still unable to retrieve the form fields when creating the pdf from scratch via Aspose.Pdf.Generator.Pdf and using the following code to try to retrieve the fields:


System.Collections.Generic.List fields = new System.Collections.Generic.List();

foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form)
{
fields.Add(formField.Name + " " + formField.Value);
}

The fields list property on pdf.Form is still empty.

heatherjoanne44:
Also, I’m still unable to retrieve the form fields when creating the pdf from scratch via Aspose.Pdf.Generator.Pdf and using the following code to try to retrieve the fields:

System.Collections.Generic.List fields = new System.Collections.Generic.List();

foreach (Aspose.Pdf.InteractiveFeatures.Forms.Field formField in pdfDocument.Form)
{
fields.Add(formField.Name + " " + formField.Value);
}

The fields list property on pdf.Form is still empty.
Hi,

In order to add form fields to PDF document, we recommend you to please try using the latest Document Object Model of Aspose.Pdf namespace. Please try using the following code snippet.

[C#]

Document doc = new
Document();<o:p></o:p>

Page page = doc.Pages.Add();

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();

table1.ColumnWidths = "120 120 120";

page.Paragraphs.Add(table1);

Aspose.Pdf.Row row1 = table1.Rows.Add();

Aspose.Pdf.Cell cell1 = row1.Cells.Add("Name");

Aspose.Pdf.Cell cell2 = row1.Cells.Add("City");

Aspose.Pdf.Cell cell3 = row1.Cells.Add("State");

TextBoxField field = new TextBoxField();

field.PartialName = "f1";

field.Value = "1";

field.Width = 80;

field.Height = 15;

TextBoxField field2 = new TextBoxField();

field2.PartialName = "f2";

field2.Value = "2";

field2.Width = 80;

field2.Height = 15;

TextBoxField field3 = new TextBoxField();

field3.PartialName = "f3";

field3.Value = "3";

field3.Width = 80;

field3.Height = 15;

page.Paragraphs.Add(field);

page.Paragraphs.Add(field2);

page.Paragraphs.Add(field3);

doc.Save(“c:/pdftest/FieldTest.pdf”);


In order to retrieve form field values, please try using the following code snippet.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/FieldTest.pdf");

//get values from all fields

foreach (Field formField in pdfDocument.Form)

{

Console.WriteLine("Field Name : {0} ", formField.FullName);

Console.WriteLine("Value : {0} ", formField.Value);

}

heatherjoanne44:
Hi, I have downloaded the latest release, and I’m still unable to retrieve the image from the signature field in the pdf using the following code:
System.IO.Stream signature= pdfSignature.SignatureAppearanceStream. The SignatureAppearanceStream property is still null. Is there a new way to retrieve the image from the signature field?
Hi,

I am afraid the feature to extract image from Signature field is currently not supported. However for the sake of correction, we already have logged this requirement as PDFNEWNET-36044 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.

The issues you have found earlier (filed as PDFNEWNET-36044) have been fixed in Aspose.Pdf for .NET 9.0.0.

Hi,

Thanks for your patience.

In order to accomplish the requirement PDFNEWNET-36044, please follow the instructions specified over