开发者

Filling in a pdf form with aspose

I am trying to use Aspose to set the values of fields in a pdf. This pdf works fine in ITextSharp. That is the main frustration I am experiencing.

Here's my code

string outputPdf = String.Format(@"C:\PDF\output\test{0:dd-MM-yyyy-HH-mm-ss}.pdf", DateTime.Now);
string inputPdf = @"C:\PDF\application.pdf";

Aspose.Pdf.Facades.Form form = new开发者_开发知识库 Aspose.Pdf.Facades.Form(inputPdf, outputPdf);

form.FillField("MY_FIELD", "Test Value");

form.FlattenAllFields();
form.Save();

the line Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form(inputPdf, outputPdf); is causing an error.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Here's the stacktrace

[NullReferenceException: Object reference not set to an instance of an object.] Aspose.Pdf.EmbeddedFileCollection.( node, Hashtable hash) +57 Aspose.Pdf.EmbeddedFileCollection..ctor(Document document) +161 Aspose.Pdf.Document.() +58 Aspose.Pdf.Document.(Stream input, String password) +181 Aspose.Pdf.Facades.Form..ctor(String srcFileName, Stream destStream) +92


I posted on their forums and it appears Aspose.Pdf 6.0.0 has known bugs due to a project merge between Aspose.Pdf and Aspose.Pdf.Kit. I am unable to open a Document or access the form in 6.0.0, so I grabbed Aspose.Pdf.Kit 5.6.0 and I was able to make it work.

Aspose.Pdf.Kit.Form form = new Aspose.Pdf.Kit.Form(inputPdf, outputPdf);

form.FillField("MyField", "Some Value");

Hope that helps anyone else who tries to use their software. After I did that, everything works fine for my demo version.


Have you tried Aspose.Pdf for .NET 6.2.0? Our team is also reviewing the upcoming version 6.3.0 which will be published in a week. Please try the latest one. If you still find any such issue please report it along with the input PDF file in Aspose.Pdf forum so our team could help you resolve this issue.

Disclosure: I work as developer evangelist at Aspose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜