So I’m looking for help. Just upgraded to the latest version and now I’m getting an error when I go to save my PDF.
Aspose.Pdf.Document form = this.affordableFormService.GetForm(accountID, pdfName, certificationID, System.Web.HttpContext.Current.Server.MapPath("~/Content/forms/"), complianceVerification, new ResManSimpleInjector(accountID));
if (form != null)
{
string contentType = “application/pdf”;
MemoryStream _ms = new MemoryStream();
form.Save(_ms, Aspose.Pdf.SaveFormat.Pdf); <- here is where error is caused.
byte[] bytes = _ms.ToArray();
_ms.Flush();
_ms.Close();
return File(bytes, contentType);
}
The error is
An exception of type ‘System.ArgumentNullException’ occurred in mscorlib.dll but was not handled in user code
Additional information: Value cannot be null.
at System.Collections.Generic.Dictionary2.FindEntry(TKey key)</div><div> at System.Collections.Generic.Dictionary
2.ContainsKey(TKey key)
at . (String )
at . (String )
at Aspose.Pdf.XFormCollection. (String )
at Aspose.Pdf.Artifact. ()
at Aspose.Pdf.Artifact…ctor(ArtifactCollection , , List1 , )</div><div> at Aspose.Pdf.HeaderArtifact..ctor(ArtifactCollection , , List
1 , )
at Aspose.Pdf.ArtifactCollection. ( , List1 , )</div><div> at Aspose.Pdf.ArtifactCollection. (Matrix , OperatorCollection , Resources , List
1 )
at Aspose.Pdf.ArtifactCollection. ()
at Aspose.Pdf.ArtifactCollection.Add(Artifact artifact)
at Aspose.Pdf.Page. (Page )
at Aspose.Pdf.Page. (Page )
at Aspose.Pdf.Page. (Page )
at Aspose.Pdf.Page. ()
at Aspose.Pdf.Document.ProcessParagraphs()
at Aspose.Pdf.Document.Save(Stream output)
at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options)
at Aspose.Pdf.Document.Save(Stream outputStream, SaveFormat format)
at ResMan.Web.Controllers.CertificationsController.PrintForm(Guid certificationID, String pdfName) in c:\Workspaces\2017-03\ResMan.Web\Controllers\CertificationsController.cs:line 923
at ResMan.Web.Controllers.CertificationsController.SelectFormForPrint(FormSelectPrintViewModel model) in c:\Workspaces\2017-03\ResMan.Web\Controllers\CertificationsController.cs:line 909
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters)</div><div> at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.b__41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _)</div><div> at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult
1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()
I’ve seem to narrowed it down to this block of the PDF.
foreach (WidgetAnnotation ann in page.Annotations)
{
…
Aspose.Pdf.Drawing.Graph graph3 = new Aspose.Pdf.Drawing.Graph(100, 400);
// Add graph object to paragraphs collection of page instance
page.Paragraphs.Add(graph3);
// Create Rectangle instance
Aspose.Pdf.Drawing.Circle rect3 = new Aspose.Pdf.Drawing.Circle((float)ann.Rect.LLX - 82, (float)ann.Rect.LLY - 315, (float)ann.Rect.Height / 2);
// Add rectangle object to shapes collection of Graph object
graph3.Shapes.Add(rect3);
}
Because if I skip this block it works fine. But when this section is included on the PDF generation I get the error when I save.