Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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
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
using iTextSharp.text;
using iTextSharp.text.pdf;
 
Can someone please tell me what the problems is?
Posted 14-Feb-13 7:09am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The Color class[^] resides in Sytem.Drawing namespace.
  Permalink  
Comments
stevenandler at 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 at 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 at 14-Feb-13 14:16pm
   
5ed.
—SA
stevenandler at 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ő at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try BaseColor instead of Color
  Permalink  

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

  Print Answers RSS
0 Nirav Prabtani 318
1 OriginalGriff 227
2 Sergey Alexandrovich Kryukov 216
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 24 Jun 2014
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