Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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.
 

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 15-Jun-12 4:49am
Edited 15-Jun-12 5:13am
Tim Corey91.7K
v3
Comments
Sandeep Mewara at 15-Jun-12 10:17am
   
What is the exact error?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
MikeVaros at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 337
1 DamithSL 310
2 OriginalGriff 220
3 Zoltán Zörgő 149
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 15 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100