PDF AutoFiller

I am trying to use the AutoFiller with a pdf that has several fields in it that have been copied with Adobe Acrobat Professional. The originally tried the AutoFiller with only one set of fields, but then I created multiple copies of the fields and the AutoFiller doesn't work anymore. Also, after copying the fields in Adob Pro the fields show up with numbers after their names. For instance, the field 'GrossDistribution' is now 'GrossDistribution.0.0.0.0' and 'GrossDistribution.0.0.0.1' and 'GrossDistribution.0.0.0.2'. I've attached the PDF so that you can see. It seems that Adobe is using some sort of array notation in the names. I have read your wiki article on Adobe field names and I have even opened the PDF in notepad to look and see what the field names really are. In notepad the field name shows up as just 'GrossDistribution'. It does look like they have it arranged hierarchal though. It seems like the autofiller should handle this since they are all the same field name.

Thanks!

Paul

Hi,

Thank you for considering Aspose.

I don’t think that I have understand your requirments. Could you please send us test code that can reproduce this error.

Thanks.

I have attached a sample solution that hopefully will help. In the solution there are two pdfs:

fieldsexample1.pdf and fieldsexample2.pdf

fieldsexample1.pdf works correctly when the autofill is done.

fieldsexample2.pdf does not work when the autofill is done. It is different than the first one because all the fields were copied from within Adobe Acrobat Pro. When it creates multiple copies of the field it names them with special names that indicate they are part of an array. However, the names that it shows (ie. 'GrossDistribution.0.0.0.0) is not the real name of the field. If you look at the pdf in notepad you can tell that the name really is 'GrossDistribution' (no numbers). So what I need is for the AutoFill to still work for these types of fields.

Hope this helps.

Dear pdeweese,

Thanks for considering Aspose.Pdf.Kit.

I think I have caught what you meant. I did the following steps:

1. I tested the code and examples you provided, it failed actually.

2. I invesgated into the PDF document. Everything is as you said, the fields of three corresponding fields are exactly the same, like "GrossDistribution". You cannot find any text such as "GrossDistribution.0.0.0.0" in it. However, in Adobe Acrobat Professional 8.0 you can clearly notice that they have different names such as "GrossDistribution.0.0.0.0" ,"GrossDistribution.0.0.0.1" and "GrossDistribution.0.0.0.2" . But I found that the three are all the Kids of one object. I think that could be the reason.

3. I opened fieldsexample1.pdf in Adobe Acrobat Professional 8.0 and copied all fields twice and created the same document as fieldsexample2.pdf. However, three corresponding fields have the same field names like "GrossDistribution". When you fill any of them, the other two will be changed to the value you filled at once. I.e, they acted just as one field.

4. I opened fieldsexample1.pdf in Adobe LiveCycle Designer 8.0 and also copied all fields twice and created the same document as fieldsexample2.pdf. However, three corresponding fields have the field names like "GrossDistribution[0]", "GrossDistribution[1]" and "GrossDistribution[2]".

From the above, I have two questions:

1. I am wondering how you create fieldsexample2.pdf ? I should admit that I have never met a document as this one. And I will really appreciate your help to find out the relationship between these field names.

2. Suppose AutoFiller did work for fieldsexample2.pdf, what's your plan to do with filler2.ImportDataTable(dataSet.Tables[0]); ? As far as I known, your PdfData.xml only contained a 5*5 data table, so it cannot be applied to a 3*5*5 template.

Best regards.

1 - I create fieldsexample2.pdf based on fieldsexample1.pdf. I have to use Adobe Acrobat professional to do the field editing since my company is not the original author of the pdf, and Acrobat is the least invasive way to add fields. When we use Live Cycle Designer it slightly changes the layout of the pdf when you import it in and that is not acceptable. From within Acrobat Pro 7.0, I open fieldsexample1.pdf. I select all of the fields except the ones for the envelope section at the bottom. Once selected, I right click on one of them and choose 'Create Multiple copies'. This brings up a dialog, that lets me pick how many copies across and down you would like. I pick 3 across and 2 down. I can then change the width and height spacing to line up the fields for the other sections of the form. If you try this, you should be able to see what a great way this is to create fields for this type of form. Since for this form, I only need 3 sections acroos the top and 1 section across the bottom, I delete the other 2 sections manually. After I accept the dialog, it makes the changes and then you can see the new field names. If you try it, the new field name for 'GrossDistribution' should be

Row 1 = 'GrossDistribution.0.0' and 'GrossDistribution.0.1' and 'GrossDistribution.0.2'

Row 2 = 'GrossDistribution.1.0'

2 - I'm not sure I completely follow you about the 3*5*5 template. I think the '3' part refers to the 3 identical sections that I have. So that is why I only supply 5*5 data, hoping that the autofiller will take the 5*5 data and apply it to all '3' sections. If I don't use the 'Create Multiple Copies' function, and instead just manually create additional matching boxes and give them the same name, then the autofiller will work. But in order to save time and increase accuracy, we really need to be able to use the 'Create Multiple Copies' feature and still be able to use the AutoFiller.

Also, just wanted to mention that I am already a customer. My company is Levi, Ray & Shoup, Inc and we have an enterprise license for Aspose.Total. We hope to get this resolved as soon as possible.

Thanks - Paul

Dear Paul,

So you created it with Acrobat Pro 7.0, and what you want is to fill "GrossDistribution.0.0.0.0" ,"GrossDistribution.0.0.0.1" and "GrossDistribution.0.0.0.2" wth the same value, right?

I will follow your way and try it again. And if the bug is confirmed, I will give you an ETA.

Best regards.

Yes, that is correct. If you try it, the fields names might not come out with so many 0's. You will probably end up with "GrossDistribution.0.0" ,"GrossDistribution.0.1" and "GrossDistribution.0.2". This might seem kind of confusing but for the example I gave you, I had copied the fields twice and so it added more zeros. I tried the AutoFiller for both examples and it didn't make a difference though. I hope that wasn't too confusing, but I didn't want you to be confused when your fields get named slightly different than the example that I gave you.

Dear Paul,

Now I totally understood your requirement. You want to create several copies from a group of fields with Adobe function 'Create Multiple Copies' , then fill them with Form.AutoFiller(), identical fields with the same value.

After my investigation, I think it is a new feature, instead of a bug of AutoFiller. Actually, you can copy those fields manually, as you already noticed. However, you decided not to do this "in order to save time and increase accuracy". Did you have many documents like fieldsexample1.pdf to be handled in this way? If not, since this requirement is unpopular, we are not very eager to support this feature. And you can do it manually. But if so, we will upgrade our product for your special requirement, maybe costing several days.

Waiting for your response. Thanks.

yes, we have many documents. As you may have noticed, it is a tax form. We have several to do each year and we have to go back and do all years since 1996 and we have do them for each year in the future as them come out. Plus since these are scannable tax forms, accuracy is very important.

I don't know whether it is a bug or a feature I suppose that is up to you. However, does your pdf toolkit offer any way to fill these type of fields? Even with the Form object? If there isn't any way to access and work with these field values then that seems to be at the very least a big whole in the forms support if you can't get to certain types of fields.

My company has paid you guys a lot of money and so far with everything that we try there has been some issue with it. So me and other developers have to waste lots of time putting in support cases and waiting on responses and fixes. My manager does not like this, but his only consolation is that in most cases you do fix the problem, eventually. So we would be most appreciative if you could make this work for us. I would like to report to my manager that you guys are taking care of the issue.

Thanks - Paul

Dear Paul,

OK, now I understood both your situation and requirement totally. I reported this issue as [PDFKITNET-3745]. I wish this will be solved in two weeks.

Best regards.

Thank you for working with us on this. Two weeks should be fine.

Thanks - Paul

Dear Paul,

I am afraid I have to discuss this problem with you again.

After my investigation, I found that the field name with suffix (ie. 'GrossDistribution.0.0.0.0) is actually the real name of the field. Remember that I said that I found that the three ("GrossDistribution.0.0.0.0" ,"GrossDistribution.0.0.0.1" and "GrossDistribution.0.0.0.2" ) are all the Kids of one object. Please referring to https://forum.aspose.com/t/131168 about the definition of field name. The reason of failure because of the wrong field name you got from the XML.

I have two suggestions ( I will take your attachment as example):

1. To replicate all data in DataSet.Tables for 4 times and get a bigger table, then add suffix (such as ".0.0.0.0", ".0.0.0.1", ".0.0.0.2", ".0.0.0.3") to the field name in each Table. Then you can use autofiller as usual.

2. We provide another function AutoFiller.ImportDataTable(dataSet.Tables, int copyRow, int copyColumn) to fill your special requirement, and you should provide two additional parameters to indicate how many copies you have created using 'Create Multiple copies'.

Waiting for your response.

Dear Paul,

I am afraid I have to discuss this problem with you again.

After my investigation, I found that the field name with suffix (ie. 'GrossDistribution.0.0.0.0) is actually the real name of the field. Remember that I said that I found that the three ("GrossDistribution.0.0.0.0" ,"GrossDistribution.0.0.0.1" and "GrossDistribution.0.0.0.2" ) are all the Kids of one object. Please referring to https://forum.aspose.com/t/131168 about the definition of field name. The reason of failure is because of the wrong field name you got from the XML.

I have two suggestions ( I will take your attachment as example):

1. To replicate all data in DataSet.Tables for 4 times and get a bigger table, then add suffix (such as ".0.0.0.0", ".0.0.0.1", ".0.0.0.2", ".0.0.0.3") to the field name in each Table by yourself. Then you can use autofiller as usual. Thus AutoFiller need no more modification, and this is my preferred.

2. If the above is unacceptable, we can provide another function AutoFiller.ImportDataTable(dataSet.Tables, int copyRow, int copyColumn) to fill your special requirement, and you should provide two additional parameters to indicate how many copies you have created using 'Create Multiple copies'. But you should notice that this is only a customized service.

Waiting for your response.

I tried to verify that the autofiller could do what you said it can do in #1, but when I run the example that I had previously attached, it now gets an error. The only thing that changed is that I upgraded to pdf kit 2.6.1.0 to try and fix another case that is open (it didn't fix it). The error that I get is below.

"x833cb12bef83f1f9.xc048bd652dc413fb was unhandled
Message="Courier is not found as an embedded resource."
Source="Aspose.Pdf.Kit"
StackTrace:
at xeb116a323308e2f7.xc19484cc31391ae1.setField(String name, String value_Renamed)
at Aspose.Pdf.Kit.Form.FillField(String fieldName, String fieldValue)
at Aspose.Pdf.Kit.AutoFiller.ImportDataTable(DataTable dataTable)
.......

Also, as a further test, I edited the file PDFData.xml file in the previously attached project, so that it would have the field names with the new form (ie. ). However, when I use this format I get a different error from the previously attached project. The error occurs when I try to do an AutoFiller.Save(). The error is below:

System.IO.IOException was unhandled
Message="Invalid pdf format:pdf head signature is not found!"
Source="Aspose.Pdf.Kit"
StackTrace:
at xeb116a323308e2f7.xa780c1549f927915.checkPdfHeader()
at xeb116a323308e2f7.x7759a935a2782a02.readPdf()
at xeb116a323308e2f7.x7759a935a2782a02..ctor(Stream is_Renamed, SByte[] ownerPassword)
at xeb116a323308e2f7.x7759a935a2782a02..ctor(Stream is_Renamed)
at Aspose.Pdf.Kit.PdfFileEditor.x2f6504d9cec3db1e(Stream[] xbdeb1e89c00b5b84)
at Aspose.Pdf.Kit.PdfFileEditor.Concatenate(Stream[] inputStreams, Stream outputStream)
at Aspose.Pdf.Kit.AutoFiller.Save()

Hi,

The first question is because of the font resource.And the second one is due to multiple stream concating. We will discuss them soon. And what about my 2# suggestion? If it is acceptable, I will provide a new interface for you.

Best regards.

I reverted back to an earlier version of pdf.kit and the errors went away. I did a test with Form.FillField to verify that referring to the field with the .0.0.0.0 notation would work correctly (which it did). I think at this point the best thing for me to do is to go ahead and make my own AutoFiller that uses Form.FillField and that concatenates all the pdf's together. I can then have it fill all the fields with similar names by adding on the necessary extension and filling each copy individually.

Are you going to do another hotfix to fix the font problem and the concatenation problem?

For your option #2 with the customzied service, were you meaning you would charge for that?

Hi pdeweese,

You are quite right, I also did the same experiment with Form.FillField. The method you mentioned in post 96650 will surely work fine as a workaround, although it is much more complex than employing AutoFiller directly (i.e. option 1#). We are also considering about option 2#, too. The precondition is to make it common and reliable. BTW, how can you get suffix such as "0.0.0.0", "0.0.0.1"? I only got "0.0" or "0.1" by "Create Multiple Fields".

You also mentioned that an earlier version avoided both problems, so what's the version serial number? The font and the concatenation problem are both undertaking now, and the ETA will be in one week. Before this, please degrade to that old version for your convenience.

Thanks for your patience & Best regards.

I have already put together my own working AutoFiller that fills in all fields with the same name. If the name on the form has some sort of array notation like '0.1, or 0.2', then that field is considered the same. This method seems to work the best for what we are doing, so that we do not have to know the array dimensions for the fields on the form. I think this will solve my problem.

As far as getting a field with 0.0.0.0, you have to use the create copies feature on a field that has already been copied.

The version that we are using now that does not get the errors is 2.5.2.0.

Congratulations!

I think this is the best way for your special requirement, too. And thanks for you useful information. We will continue on the two bugs you reported at thread 96517.

Best regards.