FieldList null?

FieldList null?

Forum member · Apr 5, 2006
I am trying to use the code below.. However, mergeDocument.Form.Fields comes back as null and blows up, any idea why? I am trying to enumerate through the form fields and via reflection get a objects value and place that value in the form. I have attached the pdf. Thanks for your help. --- namespace Mimi.SL.Reporting { using System; using System.IO; using System.util; public class HardAppBase { private NHibernate.ISession _session = null; private Mimi.DM.Application _app = null; private byte[] _pdfBytes; private string _sourcePDF; private ceTe.DynamicPDF.Forms.FormFieldList _formFieldList = null; private long _appId; public long AppId { get { return _appId; } set { _appId = value; } } public HardAppBase(long appId) { _appId = appId; Mimi.DM.NHibernate.BeginSession(ref _session); _app = (Mimi.DM.Application)_session.Get(typeof(Mimi.DM.Application), _appId); if (_app == null) throw new Exception("The application was not found."); _sourcePDF = @"G:\development\mimi\trunk\mimi\reports\reports\concord.pdf"; ceTe.DynamicPDF.Merger.MergeDocument mergeDocument = new ceTe.DynamicPDF.Merger.MergeDocument(_sourcePDF); _formFieldList = mergeDocument.Form.Fields; Map(); this._pdfBytes = mergeDocument.Draw(); } private void Map() { if (_app == null || _formFieldList == null) throw new Exception("App and/or AcroFields were not set"); for (int i = 0; i < _formFieldList.Count; i++) { ceTe.DynamicPDF.Forms.FormField formField = _formFieldList[i]; formField.Value = "Wow"; } } public System.Web.UI.UserControl GetPreviewPane() { return null; } public byte[] GetPdf() { return _pdfBytes; } } }

Re: FieldList null?

Support · Apr 5, 2006
Hello, You are getting a null value because none of the form fields are being preserved in the merged document. You will have to set MergeOptions to true in order to preserve form fields from existing PDF document. Following is the code snippet in order to preserve form fields from existing PDF document: MergeDocument document = new MergeDocument( @"C:\concord.pdf ", new MergeOptions( true ) ); Thanks, ceTe Software Support Team