Reputation: 16567
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
Upvotes: 1
Views: 4554
Reputation: 1424
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.
Upvotes: 2
Reputation: 16567
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.
Upvotes: 3