I downloaded trail version of PDFNet SDK .NET 4 (32-bit Windows)
added the PDFNet dll as a reference to new .net4 website application
and added a new aspx page. In the page load I added the following
code:
protected void Page_Load(object sender, EventArgs e)
{
string pdfPath = Server.MapPath("w9-saved.pdf");
byte[] pdfFileContents = File.ReadAllBytes(pdfPath);
PDFNet.Initialize();
using (PDFDoc pdfDocument = new PDFDoc(pdfFileContents,
pdfFileContents.Length))
{
pdfDocument.InitSecurityHandler();
FieldIterator fieldIterator =
pdfDocument.GetFieldIterator("some");
if (fieldIterator != null)
{
Field currentField = fieldIterator.Current();
try
{
currentField.SetValue("test");
}
catch (Exception ex) // couldnt find the
fieldName, so return without any error.
{ return; }
}
}
PDFNet.Terminate();
}
When I run it, I get the following System.AccessViolationException
error:
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often
an indication that other memory is corrupt.
Source=PDFNet
StackTrace:
at trn.PDF.Field.SetValue(Field* , UString* )
at pdftron.PDF.Field.SetValue(String value)
at PdftronTest.FillData.Page_Load(Object sender, EventArgs e)
in C:\SertifiKlin\_______Projects\PdftronTest\PdftronTest
\FillData.aspx.cs:line 34
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr
fp, Object o, Object t, EventArgs e)
at
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext
context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.filldata_aspx.ProcessRequest(HttpContext context) in c:
\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
\root\810432b5\3a3d584f\App_Web_bauftdob.0.cs:line 0
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
at
System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception
error)
at
System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext
context, AsyncCallback cb, Object extraData)
at
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at
System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
at Microsoft.VisualStudio.WebHost.Request.Process()
at
Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at
Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(Object
acceptedSocket)
at
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
ignoreSyncCtx)
at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
InnerException:
I search google groups, found this post:
http://bit.ly/faGh2I and the solution in it doesnt solve my problem.
Do you recommend any correct solution?
Thanks,
Uday