We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

FormEditor.MoveField throws System.NullReferenceException

Whenever I try to move a field for this document an exception is thrown. What am I doing wrong? Is it a bug? I tried doing a Document.Repair() and there was no change. I tried directly changing the rect attribute of the field without the formeditor and no change. Please advise.

        var fil = Path.GetTempPath() + Guid.NewGuid().ToString() + ".pdf";
        using (WebClient client = new WebClient()) client.DownloadFile("https://www.irs.gov/pub/irs-pdf/fw4.pdf", fil);
        var doc = new Document(fil);
        //doc.Repair();//no change
        var fe = new FormEditor(doc);
        var fld = doc.Form.Fields.First();
        var rect = new Rectangle(fld.Rect.LLX, fld.Rect.LLY, fld.Rect.URX, fld.Rect.URY);
        //Object reference not set to an instance of an object.
        //at Aspose.Pdf.Forms.Form. (Int32)
        //at Aspose.Pdf.Forms.Field.set_Rect(Rectangle value)
        //at Aspose.Pdf.Facades.FormEditor.MoveField(String fieldName, Single llx, Single lly, Single urx, Single ury)
        //at bugdemo.Program.Main(String[] args)
        fe.MoveField(fld.FullName, (float)rect.LLX, (float)rect.LLY, (float)rect.URX, (float)rect.URY);

@tvoght,
We have tested your PDF document and code with the latest version 17.8 of Aspose.Pdf for .NET API, and managed to replicate the said error in our environment. It has been logged under the ticket ID PDFNET-43198 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. We are sorry for the inconvenience caused.

Best Regards,
Imran Rafique

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan