Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Here is a snippet of code which I found on another Code Project post.

using System;
using System.Collections.Generic;
using System.Text;

using iTextSharp.text; 
using iTextSharp.text.pdf; 


namespace pdf
{
    class Program
    {
        static void Main(string[] args)
        {

            Rectangle pageSize = new Rectangle(144, 720); 
             pageSize.BackgroundColor = new Color(0xFF, 0xFF, 0xDE); 
             Document document = new Document(pageSize); 

        }
    }
}

The line
C#
pageSize.BackgroundColor = new Color(0xFF, 0xFF, 0xDE);


generates the following Build error message
The type or namespace name 'Color' could not be found (are you missing a using directive or an assemble reference?)

I have added the itextsharp.dll as a reference and have included the using directives
C#
using iTextSharp.text;
using iTextSharp.text.pdf;


Can someone please tell me what the problems is?
Posted
Updated 20-Jul-16 22:26pm

The Color class[^] resides in Sytem.Drawing namespace.
 
Share this answer
 
Comments
stevenandler 14-Feb-13 13:37pm    
Since This is a Console project, I need to add the System.Drawing Reference as well as the using System.Drawing statement. As soon As I add this, I now have 9 errors. Is this happening because I cannot add the Sytem.Drawing namespace to a console project?
Sergey Alexandrovich Kryukov 14-Feb-13 14:16pm    
No.
You are not adding namespaces! You are adding references. You always can add this assembly to your project, console or not. Why not, indeed? The errors? Just consider them one by one instead of asking this way...
—SA
Sergey Alexandrovich Kryukov 14-Feb-13 14:16pm    
5ed.
—SA
stevenandler 14-Feb-13 15:07pm    
Sorry if my question was inappropriate. One last thing on this topic. Can you please tell me where I can find a user's manual for itextsharp?

Thank you.
Zoltán Zörgő 14-Feb-13 15:22pm    
I know of no official one, but this looks good: http://www.mikesdotnetting.com/Article/80/Create-PDFs-in-ASP.NET-getting-started-with-iTextSharp
Try BaseColor instead of Color
 
Share this answer
 
Change color to BaseColor it will work
 
Share this answer
 
HI,

Generally the line
Quote:
pageSize.BackgroundColor = new Color(0xFF, 0xFF, 0xDE);

needs a namespace that contains the defination for the pagesize and backgroundcolor. And to access the class you need to include the dll to your project 1st.

The error says you are missing the assembly reference as the dll is missing. Simply add the dll to your project and your work will be done.

Thanks
 
Share this answer
 
Comments
[no name] 14-Feb-13 23:35pm    
PLease provide a reason for down voting...

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