Free Support Forum - aspose.com

Facades.Form doesn't handle all PDFs correctly

Here I am again:

Attempting to fill form fields in a PDF file and I’m getting exception at this line:

doc.FillField( mergeValue.Name, value );

doc is obviously a Facades.Form object. The value is a string. And Here’s the exception:

System.Web.HttpUnhandledException (0x80004005): Exception of type
‘System.Web.HttpUnhandledException’ was thrown. —>
System.ArgumentException: Key path ‘N’ doesn’t correspond appearance dictionary
structure.
at
Aspose.Pdf.InteractiveFeatures.Annotations.AppearanceDictionary.get_Item(Object
key)
at
Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation.(String ,
Annotation )
at
Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation.(Annotation )

at Aspose.Pdf.InteractiveFeatures.Forms.Field.()
at
Aspose.Pdf.InteractiveFeatures.Forms.Field.setValue(String value)
at
Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.set_Value(String value)
at
Aspose.Pdf.Facades.Form.FillField(String fieldName, String fieldValue)

This file is attached as MN_CS_AppOriginal.pdf.
But you know, the PDF was made with an old version of Acrobat (not that that’s an excuse to raise exceptions with a valid PDF) but I decided to open the PDF in question, and re-save it using Adobe Acrobat X.

Well, now this exception is raised at the same line:
System.Web.HttpUnhandledException (0x80004005): Exception of type
‘System.Web.HttpUnhandledException’ was thrown. —>
System.ArgumentException: Invalid font name
at
Aspose.Pdf.Text.FontCollection.get_Item(String name)
at
Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.createAppearanceProgram(AppearanceParameters
parameters, Annotation annotation)
at
Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation.(Annotation )

at Aspose.Pdf.InteractiveFeatures.Forms.Field.()
at
Aspose.Pdf.InteractiveFeatures.Forms.Field.setValue(String value)
at
Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.set_Value(String value)
at
Aspose.Pdf.Facades.Form.FillField(String fieldName, String fieldValue)

This file is attached as MN_CS_App2.pdf.
The mergefield in question is ‘Zip’.


I can get the PDF to work by re-setting the font for the Zip merge field, but that doesn’t make this acceptable. No other programs crash when dealing with these PDFs. The same PDFs worked with Pdf.Kit. There’s hundreds of PDFs in these systems and I shouldn’t have to go through all of them and make sure they work with this new library.

No replies in four days?

Hi Sam,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for the delay in response.

Sam.Rueby:

Attempting to fill form fields in a PDF file and I'm getting exception at this line:

doc.FillField( mergeValue.Name, value );

doc is obviously a Facades.Form object. The value is a string. And Here's the exception:

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Key path 'N' doesn't correspond appearance dictionary structure.
at Aspose.Pdf.InteractiveFeatures.Annotations.AppearanceDictionary.get_Item(Object key)
at Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation.
[1](String , Annotation )
at Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation.
[1](Annotation )
at Aspose.Pdf.InteractiveFeatures.Forms.Field.
[1]()
at Aspose.Pdf.InteractiveFeatures.Forms.Field.setValue(String value)
at Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.set_Value(String value)
at Aspose.Pdf.Facades.Form.FillField(String fieldName, String fieldValue)

This file is attached as MN_CS_AppOriginal.pdf.

We have found your mentioned issue after an initial test. Your issue is registered in our issue tracking system with issue id: PDFNEWNET-31931. We will notify you regarding any update against your issue via this forum thread.

Sam.Rueby:

But you know, the PDF was made with an old version of Acrobat (not that that's an excuse to raise exceptions with a valid PDF) but I decided to open the PDF in question, and re-save it using Adobe Acrobat X.

Well, now this exception is raised at the same line:
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Invalid font name
at Aspose.Pdf.Text.FontCollection.get_Item(String name)
at Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.createAppearanceProgram(AppearanceParameters parameters, Annotation annotation)
at Aspose.Pdf.InteractiveFeatures.Annotations.WidgetAnnotation.
[1](Annotation )
at Aspose.Pdf.InteractiveFeatures.Forms.Field.
[1]()
at Aspose.Pdf.InteractiveFeatures.Forms.Field.setValue(String value)
at Aspose.Pdf.InteractiveFeatures.Forms.TextBoxField.set_Value(String value)
at Aspose.Pdf.Facades.Form.FillField(String fieldName, String fieldValue)

I am unable to notice this issue and FillField method works fine. When I re-save the file using Adobe Acrobat X, I can fill the form fields without any issue. Please try the latest version of Aspose.Pdf for .NET v6.4.2 and if you still face the issue, please share some more information regarding this issue e.g. field name which is causing the problem, font name which is giving the issue etc.

Sorry for the inconvenience,

Thank you for putting in issue PDFNEWNET-31931. Hopefully it’s as “show-stopper” status.

You’re right that in 6.4.2, the issue no longer exists. I was using 6.3.0.


Embarrassingly, the series of tests I’ve created to run every time I update to your latest DLLs ever since I realized how unreliable they are are showing problems with at least one feature that was already working fine. Now, when I created PDFs that have bookmarks, “ghost” bookmarks are being inserted for every bookmark being added. A PDF with a single bookmark will now have a PDF with a blank bookmark, and the bookmark inserted.

Hi Sam,

Please accept our apologies for the issues you are facing and our development team is working hard to resolve the issues. Please share your sample code, template and generated PDF document which is causing the bookmarks issue. This will help us identify the issue soon and fix it accordingly.

Sorry for the inconvenience,

It’s not a specific PDF. It happens every time I create bookmarks, for all PDFs. But here is an example of a PDF I generated with the bookmark issue.

Hi Sam,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the resultant file.

I tried to create the bookmarks in an existing PDF file with the latest version and I am not able to generate the issue as in your resultant file. I also used the file shared by you and added the bookmarks to it and it works fine too. Please share the template PDF file you are using and the sample code. This will help us reproduce the issue at our end.

Sorry for the inconvenience,

I’ve isolated the code we’re attempting to run and have confirmed the code in this solution is displaying the problem. Adobe Reader X is being used to view the “output.pdf” result file.

Hi Sam,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the sample application.

I am able to notice the issue regarding bookmarks. The issue has been registered in our issue tracking system with issue id: PDFNEWNET-31991. We will update you regarding the resolution of this issue in this forum thread.

Sorry for the inconvenience,

The issues you have found earlier (filed as 31931) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Thanks.

Though, the bookmark issue still exists.

Hi Sam,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback.

The fix shared with you is for issue PDFNEWNET-31931 Facades.FillForm exception. The issue regarding bookmarks PDFNEWNET-31991 is still not resolved and you will notified when a fix is available for the issue.

Sorry for the inconvenience,

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.