Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone, I'm currently developing an application to generate pre-filled pdf's based on Database entries. I know how I'm going to do it, but the problem I am having is that every time I reference the AcroFields class, it tells me I am missing an assembly reference. I've included all of the "using" statements. I have some there that I'm not even using currently, just in an effort to reconcile this missing reference.

Thank you in advance for any advice you can offer.

As you can see below, I am using iTextSharp, and creating the application as a windows form c# application in Visual Studio 2010.

Below the Using Statments I've included the first line of my code that produces this error.


C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.xml;
using iTextSharp.text.xml.simpleparser;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using System.Collections;

foreach (DictionaryEntry de in pdfReader.AcroFields.Fields)
{
    sb.Append(de.Key.ToString() + Environment.NewLine);
}
Posted
Updated 15-Jun-12 4:13am
v3
Comments
Sandeep Mewara 15-Jun-12 10:17am    
What is the exact error?

1 solution

You have added the using statements, but if you have not added a reference to the actual DLL file in your references then you will get this error. You will also get this error if you are using a version of the DLL that does not include this method. Here is a Code Project article from 2008 that uses your code:

Programmatically Complete PDF Form Fields using Visual Basic and the iTextSharp DLL[^]

If the above two suggestions don't get you far enough, I would recommend downloading the source from this article and trying to run it. If it runs, compare it to your code to see what the difference is. Most likely it is either the missing DLL or the wrong version of the DLL.
 
Share this answer
 
Comments
MikeVaros 15-Jun-12 10:39am    
Thank you for the response, and the article. I'm actually basing this project roughly off of a C# Project by the same person who wrote the article you posted. I was able to get that assembly reference error to go away by starting a new project from scratch. But I changed that foreach above, because I'm getting other errors now. This is the code I have now. I did have the DLL Installed, and I referenced it. I am still relatively new to C#. At first the error stated it could not convert Dictionary Entry, and when I researched that, someone suggested using KeyValuePair instead)

foreach (KeyVaulePair<string, AcroFields.Item> de in pdfReader.AcroFields.Fields)
{
sb.Append(de.Key.ToString() + Environment.NewLine);
}


And these are the two errors I am getting now

Cannot convert type 'System.Collections.Generic.KeyValuePair<string,itextsharp.text.pdf.acrofields.item>' to 'PDFFieldExtractor.KeyVaulePair<string,itextsharp.text.pdf.acrofields.item>'

And
'PDFFieldExtractor.KeyVaulePair<string,itextsharp.text.pdf.acrofields.item>' does not contain a definition for 'Key' and no extension method 'Key' accepting a first argument of type 'PDFFieldExtractor.KeyVaulePair<string,itextsharp.text.pdf.acrofields.item>' could be found (are you missing a using directive or an assembly reference?)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900