|
I have a line of code in my project like
phrase.Add(new Chunk(strCompanyName, new iTextSharp.text.Font(-1,9,iTextSharp.text.Font.BOLD)));
it showing error message like
The best overloaded method match for 'iTextSharp.text.Font.Font(iTextSharp.text.Font.FontFamily, float, int)' has some invalid argument
Can any one please suggest the best overloaded method .. pls
|
|
|
|
|
abdul rafi wrote: Can any one please suggest the best overloaded method .. pls ..it doesn't mean that you should look for the "best" overload, it means that it cannot find any method that matches your parameter-signature.
You're doing three tasks in a single line. How about first creating a font, then assigning that to a chunk on a new line, and only add that when succesfull? That way one would not have to verify all three statements, but only the line where the error occurs.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'd guess you are screwing up the call by omitting the Font Family Name, and or scrambling the order of the parameters. Here's what a "good" call to create a font looks like:
font = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.WHITE);
I suggest you read this: [^] to understand using Fonts in iTextSharp:
"iText is written in Java, which means it's platform-independent. It ships with 14 AFM files containing the metrics of the 14 Standard Type 1 fonts (4 flavors of Helvetica, 4 flavors of Times Roman, 4 flavors of Courier, Symbol and ZapfDingbats).
As soon as you need other fonts, you need to register the font files by passing the path to the font directory or the path to an actual font."
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Hi Team,
I have a project in which we are using Rich Text Box Controls and trying to render emails receieved from outside world, which could be from any source like gmail/hotmail/yahoo/rediff/aol/iOS clients/Android Clients.
So here's how it happens: Source of Email>Mail Exchange Server>My Project with Rich Text Box.
Now the problems that we are facing:
1. The email is rendered but with improper tables/texts/images.
2. Sometimes images are missing completely.
3. Sometimes images are distorted.
4. Sometimes tables/frames are not in their right place.
5. Sometimes email comes completely blank.
Now the same email when opened in the WPF html browser renders almost perfectly 99% of the times.
Can anyone suggest a direct solution to it? If not then can anyone suggest an alternate to using Rich Text Box.
The reason for which we are forced to use RTB is coz' using our client the user has to respond to the emails as well, and RTB provides for formatting options for the text to be sent out and inserting images as part of the email.
Appreciate if you guys can help me out with this.
Let me know if more details are needed.
Regards,
Upkar S
|
|
|
|
|
upksinghm wrote: If not then can anyone suggest an alternate to using Rich Text Box. Any browser-control would render the HTML. The RichTextBox does not work with HTML, but with RTF. You can't do everything in RTF that you can in HTML.
upksinghm wrote: The reason for which we are forced to use RTB is coz' using our client the user
has to respond to the emails as well, and RTB provides for formatting options
for the text to be sent out and inserting images as part of the email. No one is forcing you. They have a request, and you can opt to honor it or not.
Find an editor for HTML, if HTML is what they want to edit. Or severely limit their options (like a single font and only basic markup).
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for the response.
Can you tell me how can you use an HTML editor in your .NET project for an end user and not for a programmer to use it while he runs the compiled program.
Does anyone else have any other idea?
Appreciate your help.
Regards,
Upkar S
|
|
|
|
|
Hi,
I generated a table using the library, but the data didn't show on Adobe Reader IX, it works fine if using other PDF reader or view via URL.
Could anyone know what's the problem?
Thanks in advance.
Eileen
Here is my code:
private void DrawInvoiceItemsTable(PdfContents contents, Invoice invoice)
{
contents.SaveGraphicsState();
contents.Translate(0, 0);
const double col1X = 2.2;
const double baseY = 19.25;
const double col2X = 11.1;
const double col5X = 16;
contents.SetColorNonStroking(Color.FromArgb(40, 171, 226));
contents.DrawRectangle(1.9, 19, 8.5, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, col1X, baseY, TextJustify.Left, DrawStyle.Normal, Color.White, "ITEM DESCRIPTION");
contents.DrawRectangle(10.45, 19, 4.2, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, col2X, baseY, TextJustify.Left, DrawStyle.Normal, Color.White, "POINTS ISSUED");
contents.DrawRectangle(14.7, 19, 5.5, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, col5X, baseY, TextJustify.Left, DrawStyle.Normal, Color.White, "TOTAL AMOUNT");
contents.RestoreGraphicsState();
var box = new TextBox(7.9);
var posY = 18.6;
const double fontSize = 9.0;
var lineSpace = ArialNormal.LineSpacing(fontSize);
var decent = ArialNormal.Descent(fontSize);
const double lineHeight = 0.3;
contents.SaveGraphicsState();
contents.Translate(0, 0);
for (var i = 0; i < invoice.InvoiceCharges.Count; i++)
{
box.Clear();
if (i % 2 != 0)
{
contents.SetColorNonStroking(Color.FromArgb(230, 230, 230));
contents.DrawRectangle(1.9, posY - lineSpace * 1.5, 8.5, lineHeight + lineSpace, PaintOp.Fill);
contents.DrawRectangle(10.45, posY - lineSpace * 1.5, 4.2, lineHeight + lineSpace, PaintOp.Fill);
contents.DrawRectangle(14.7, posY - lineSpace * 1.5, 5.5, lineHeight + lineSpace, PaintOp.Fill);
}
box.AddText(ArialNormal, fontSize, Color.FromArgb(85, 86, 89), invoice.InvoiceCharges[i].Description);
contents.DrawText(col1X, ref posY, 0, 0, box);
posY += decent;
contents.DrawText(ArialNormal, fontSize, col2X, posY, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), invoice.InvoiceCharges[i].PointsIssued);
contents.DrawText(ArialNormal, fontSize, col5X, posY, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), invoice.InvoiceCharges[i].Amount.ToString("c2"));
posY -= decent + lineSpace;
}
contents.DrawText(ArialNormal, 10.0, 15.2, 6.5, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), "Subtotal");
contents.DrawText(ArialNormal, 10.0, 19, 6.5, TextJustify.Right, DrawStyle.Normal, Color.Black, invoice.SubTotal.ToString("c2"));
contents.DrawText(ArialNormal, 10.0, 15.2, 6, TextJustify.Left, DrawStyle.Normal, Color.FromArgb(85, 86, 89), "GST");
contents.DrawText(ArialNormal, 10.0, 19, 6, TextJustify.Right, DrawStyle.Normal, Color.Black, invoice.GstTotal.ToString("c2"));
contents.SetColorNonStroking(Color.FromArgb(40, 171, 226));
contents.DrawRectangle(14.75, 5, 2.1, 0.8, PaintOp.Fill);
contents.DrawRectangle(16.9, 5, 3, 0.8, PaintOp.Fill);
contents.DrawText(ArialBold, 10.0, 15.2, 5.25, TextJustify.Left, DrawStyle.Normal, Color.White, "TOTAL");
contents.DrawText(ArialBold, 10.0, 18.5, 5.25, TextJustify.Center, DrawStyle.Normal, Color.White, invoice.TotalAmount.ToString("c2"));
}
|
|
|
|
|
Does it just not show data, or is the page entirely blank? And how is this a C# problem? Sounds more like a problem with the data-format.
Easy solution; use another reporting engine.
Or try and get help from Adobe, maybe they support their product.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Start here to become aware of how complex the format of a legal e-mail address can be: [^].
And, then, select an appropriate technique from: [^].
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Beside Bill's suggestions also note! Valid email address does not mean that the email is real and alive!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Removing your question after it has been answered is considered bad behavior!
Now other people cannot learn from the discussion thread.
|
|
|
|
|
I don't think he removed his question at all. It looked like this when I first saw it this morning.
|
|
|
|
|
Looking at the user's other messages, they're all the same - a vague question in the title, and a body containing nothing but a <pre> tag.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Only sure way to validate a email address is to send a email to the address with a link in it which the user then clicks on to validate the email. There are variations to this such as sending a key which the user then puts into a web site.
And unless you do that realistically you shouldn't attempt to validate at all. Not worth the time. As noted in a different response the valid form is complex and trivial validation will often be wrong (disallowing real addresses.)
|
|
|
|
|
Recently a question on QA (from a newbie) asked about the best way to selectively invoke a method in either a base class containing the method, or a class derived from the base class containing an identically named and identically functional method ... in another method that took as a parameter an instance of either the base class, or any of its derived types.
Consider the following classes:
public class BaseClass
{
public void ShowMe() {MessageBox.Show("BaseClass");}
}
public class DerivedClass1: BaseClass
{
public void ShowMe(){MessageBox.Show("DerivedClass1");}
}
public class DerivedClass2: BaseClass
{
public void ShowMe(){MessageBox.Show("DerivedClass2");}
} And, consider the following example using instnaces of the classes:
BaseClass baseClass = new BaseClass();
DerivedClass1 derivedClass1 = new DerivedClass1();
DerivedClass2 derivedClass2 = new DerivedClass2();
private void invokeClassMethod1(BaseClass theClass) {theClass.ShowMe();}
private void invokeClassMethod2(dynamic theClass) { theClass.ShowMe(); }
private void invokeClassMethod3(BaseClass theClass)
{
if(theClass is DerivedClass1)
{
(theClass as DerivedClass1).ShowMe();
} else if (theClass is DerivedClass2)
{
(theClass as DerivedClass2).ShowMe();
}
else
{
theClass.ShowMe();
}
} Obviously, 'invokeClassMethod1 will always invoke the method 'ShowMe in the BaseClass instance.
'invokeClassMethod2 uses 'dynamic declaration of the parameter Type, and "does the right thing" to invoke either the base class method, or the derived type method.
'invokeClassMethod3 does an identity check and invokes the "right" method.
Equally obvious is that this scenario calls for a restructuring of the code to declare the method in the BaseClass of type 'virtual, and to then over-ride the method in the derived classes which would then automatically invoke the right target.
The question is: what's the cost (performance, memory use, possible "risks: threading ? extensibility ? security ?) of using 'dynamic in this example compared to declaring the method in the BaseClass 'virtual and over-riding it ?
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
In a case like you I always going to see IL code - it can tell a lot about your code really looks like...
private static void invokeClassMethod1(BaseClass theClass)
{
theClass.ShowMe();
}
private static void invokeClassMethod2([Dynamic] dynamic theClass)
{
if (Program.<invokeClassMethod2>o__SiteContainer0.<>p__Site1 == null)
{
Program.<invokeClassMethod2>o__SiteContainer0.<>p__Site1 = CallSite<Action<CallSite, object>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "ShowMe", null, typeof(Program), new CSharpArgumentInfo[]
{
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
}));
}
Program.<invokeClassMethod2>o__SiteContainer0.<>p__Site1.Target(Program.<invokeClassMethod2>o__SiteContainer0.<>p__Site1, theClass);
}
This is the IL code (decopiled to C#) you will get for your first two 'invoke' method. It is obvious that the dynamic approach will add more run-time handling (as the type is unknown at compile time)...
If you pass to the first 'invoke' method a series of classes that using virtual/override approach the calling address of the right function will be searched by the basic 'engine' of the object oriented programming (a search in the virtual method table of the actual type of the object), so no need for additional code in your application...
I did not measured the difference between the dynamic search and the object oriented look-up, but I have the feeling that OO will hit dynamic...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thanks KEP; to the extent I can understand IL (very little), I get what you are saying.
In any case, from an "architectural" point of view I think it would be better to make the method 'virtual and use over-ride.
It might be interesting to look at the IL for the 'virtual+over-ride case ?
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
The case of the virtual/override has no special 'footprint' in the IL code. It is exactly the same as your first 'invoke' method...The reason is that the selection of the correct method to call done in lower level of the object oriented 'engine'. The selection is done using a virtual-method-table search, and that is part of the lower level OO mechanism. You can't see it in your code...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Kornfeld Eliyahu Peter wrote: The case of the virtual/override has no special 'footprint' in the IL code. It is exactly the same as your first 'invoke' method.
Wouldn't it be using the callvirt opcode instead of call ? It's not visible when you convert back to C#, but there is a difference in the IL.
The difference between call and callvirt can lead to some unexpected behaviour:
http://blogs.msdn.com/b/ericlippert/archive/2010/03/29/putting-a-base-in-the-middle.aspx[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Of course it is a callvirt! However C# always uses callvirt when calling instance methods! So other there is no difference between the two...
Take this code for instance:
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main ( string[ ] args )
{
BaseClass baseClass = new BaseClass( );
DerivedClass1 derivedClass1 = new DerivedClass1( );
DerivedClass2 derivedClass2 = new DerivedClass2( );
invokeClassMethod( baseClass );
invokeClassMethod( derivedClass1 );
invokeClassMethod( derivedClass2 );
BaseClassD baseClassD = new BaseClassD( );
DerivedClass1D derivedClass1D = new DerivedClass1D( );
DerivedClass2D derivedClass2D = new DerivedClass2D( );
invokeClassMethodD( baseClassD );
invokeClassMethodD( derivedClass1D );
invokeClassMethodD( derivedClass2D );
}
static private void invokeClassMethod ( BaseClass theClass )
{
theClass.ShowMe( );
}
static private void invokeClassMethodD ( BaseClassD theClass )
{
theClass.ShowMe( );
}
}
public class BaseClass
{
public virtual void ShowMe ( )
{
Debug.WriteLine( "BaseClass" );
}
}
public class DerivedClass1 : BaseClass
{
public override void ShowMe ( )
{
Debug.WriteLine( "DerivedClass1" );
}
}
public class DerivedClass2 : BaseClass
{
public override void ShowMe ( )
{
Debug.WriteLine( "DerivedClass2" );
}
}
public class BaseClassD
{
public void ShowMe ( )
{
Debug.WriteLine( "BaseClass" );
}
}
public class DerivedClass1D : BaseClassD
{
public void ShowMe ( )
{
Debug.WriteLine( "DerivedClass1" );
}
}
public class DerivedClass2D : BaseClassD
{
public void ShowMe ( )
{
Debug.WriteLine( "DerivedClass2" );
}
}
}
And see the IL code for the same:
1 .class private auto ansi beforefieldinit ConsoleApplication1.Program
2 extends [mscorlib]System.Object
3 {
4
5 .method private hidebysig static
6 void Main (
7 string[] args
8 ) cil managed
9 {
10
11
12 .maxstack 1
13 .entrypoint
14 .locals init (
15 [0] class ConsoleApplication1.BaseClass baseClass,
16 [1] class ConsoleApplication1.DerivedClass1 derivedClass1,
17 [2] class ConsoleApplication1.DerivedClass2 derivedClass2,
18 [3] class ConsoleApplication1.BaseClassD baseClassD,
19 [4] class ConsoleApplication1.DerivedClass1D derivedClass1D,
20 [5] class ConsoleApplication1.DerivedClass2D derivedClass2D
21 )
22
23 IL_0000: nop
24 IL_0001: newobj instance void ConsoleApplication1.BaseClass::.ctor()
25 IL_0006: stloc.0
26 IL_0007: newobj instance void ConsoleApplication1.DerivedClass1::.ctor()
27 IL_000c: stloc.1
28 IL_000d: newobj instance void ConsoleApplication1.DerivedClass2::.ctor()
29 IL_0012: stloc.2
30 IL_0013: ldloc.0
31 IL_0014: call void ConsoleApplication1.Program::invokeClassMethod(class ConsoleApplication1.BaseClass)
32 IL_0019: nop
33 IL_001a: ldloc.1
34 IL_001b: call void ConsoleApplication1.Program::invokeClassMethod(class ConsoleApplication1.BaseClass)
35 IL_0020: nop
36 IL_0021: ldloc.2
37 IL_0022: call void ConsoleApplication1.Program::invokeClassMethod(class ConsoleApplication1.BaseClass)
38 IL_0027: nop
39 IL_0028: newobj instance void ConsoleApplication1.BaseClassD::.ctor()
40 IL_002d: stloc.3
41 IL_002e: newobj instance void ConsoleApplication1.DerivedClass1D::.ctor()
42 IL_0033: stloc.s derivedClass1D
43 IL_0035: newobj instance void ConsoleApplication1.DerivedClass2D::.ctor()
44 IL_003a: stloc.s derivedClass2D
45 IL_003c: ldloc.3
46 IL_003d: call void ConsoleApplication1.Program::invokeClassMethodD(class ConsoleApplication1.BaseClassD)
47 IL_0042: nop
48 IL_0043: ldloc.s derivedClass1D
49 IL_0045: call void ConsoleApplication1.Program::invokeClassMethodD(class ConsoleApplication1.BaseClassD)
50 IL_004a: nop
51 IL_004b: ldloc.s derivedClass2D
52 IL_004d: call void ConsoleApplication1.Program::invokeClassMethodD(class ConsoleApplication1.BaseClassD)
53 IL_0052: nop
54 IL_0053: ret
55 }
56
57 .method private hidebysig static
58 void invokeClassMethod (
59 class ConsoleApplication1.BaseClass theClass
60 ) cil managed
61 {
62
63
64 .maxstack 8
65
66 IL_0000: nop
67 IL_0001: ldarg.0
68 IL_0002: callvirt instance void ConsoleApplication1.BaseClass::ShowMe()
69 IL_0007: nop
70 IL_0008: ret
71 }
72
73 .method private hidebysig static
74 void invokeClassMethodD (
75 class ConsoleApplication1.BaseClassD theClass
76 ) cil managed
77 {
78
79
80 .maxstack 8
81
82 IL_0000: nop
83 IL_0001: ldarg.0
84 IL_0002: callvirt instance void ConsoleApplication1.BaseClassD::ShowMe()
85 IL_0007: nop
86 IL_0008: ret
87 }
88
89 .method public hidebysig specialname rtspecialname
90 instance void .ctor () cil managed
91 {
92
93
94 .maxstack 8
95
96 IL_0000: ldarg.0
97 IL_0001: call instance void [mscorlib]System.Object::.ctor()
98 IL_0006: ret
99 }
100
101 }
See line 68 and 84 - both have callvirt event the second is not a virtual member...
I also found this...http://blogs.msdn.com/b/ericgu/archive/2008/07/02/why-does-c-always-use-callvirt.aspx[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
hi,
I want to execute mutiple sql select queries in ms access using c#. As per my knowledge what we can do with sql server, is we can separate the queries using semi colon (;) like [select * from table1 ; select * from table2] and we can fill mutiple data tables within a dataset with the help of data adapter. is there any way we can do the same in ms access.
we can not create stored procedures too in ms access so what is the way to populate multiple data tables in one go, by sending / executing multiple queries in ms access.
Thanks in advance
|
|
|
|
|
Not sure if this is the right place, but I didn't see any more appropriate place, so...
Is it possible to validate attributes with xsd?
For example (a slightly contrived example, but you'll get the idea):
<host ipAddr="" hostName="" />
Does not make any sense to have both ipAddr and hostname specified.
A google search seems to indicate that you might not be able to do this, but it seems like Visual Studio does it on XSD itself. If I specify xs:element with both ref and name, it'll tell me ref is not allowed.
I want to do exactly that.
|
|
|
|
|
|
As stated in another comment, this question belongs to XML/XSL.
It is not clear exactly what you want to do.
Do you want tot have two attributes that is mutual exclusive, so either ipAddr or hostName is present but not both?
|
|
|
|
|