|
Hi to everyone.
I know that there are a lot of articles in the internet about this problem. I know that there is KeepWith property and i read here http://forum.pdfsharp.net/viewtopic.php?f=2&t=679[^]
http://forum.pdfsharp.net/viewtopic.php?p=6852#p7408[^]
that it should work if i install assemblies http://www.pakeha_by.my-webs.org/MigraDocFastTableRender.html[^]
I installed and there is no effect, anyway i try to use it - my table is cut on one page((( and other rows do not go to the next page....
My way coding tables
PdfDocument outputDocument = new PdfDocument();
PdfPage editablePage = outputDocument.AddPage();
editablePage.Size = PageSize.A4;
XGraphics gfx = XGraphics.FromPdfPage(editablePage);
MigraDoc.DocumentObjectModel.Document doc3 = new MigraDoc.DocumentObjectModel.Document();
MigraDoc.DocumentObjectModel.Tables.Table table3 = new MigraDoc.DocumentObjectModel.Tables.Table();
Column column3 = table3.AddColumn(70);
column3.Format.Alignment = ParagraphAlignment.Left;
column3.Format.Font.Bold = false;
column3 = table3.AddColumn(50);
column3.Format.Alignment = ParagraphAlignment.Center;
column3.Format.Font.Bold = false;
Row row3 = table3.AddRow();
row3.Format.Alignment = ParagraphAlignment.Center;
row3.Format.Font.Bold = true;
row3.Format.Font.Size = 9;
row3[0].AddParagraph("Serial");
row3[1].AddParagraph("Time");
...............................................................
...............................................................
while (reader1.Read())
{
row3 = table3.AddRow();
row3[0].AddParagraph(Convert.ToString(reader1.GetValue(0)));
row3[1].AddParagraph(Convert.ToString(reader1.GetValue(1)));
}
...............................................................
...............................................................
table3.Rows[0].KeepWith = table3.Rows.Count-1;
doc3.AddSection().Add(table3);
DocumentRenderer docRenderer3 = new DocumentRenderer(doc3);
docRenderer3.PrepareDocument();
docRenderer3.RenderObject(gfx, 50, 0, 0, table3);
May be this way of constructing tables does not provide my requirements?
I will appreciate any help, thank you.
modified 13-Nov-14 12:30pm.
|
|
|
|
|
It seems i am alone here
Hey...Where are you cyberpeople?
|
|
|
|
|
PDFSharp is not a universally used tool, you might be better served but getting in their forum.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Hi,
I am trying to send email message in C# using this MSDN article:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient(v=vs.110).aspx
but I am getting this error:
Cannot access a disposed object. Object name : System.Net.Mail.MailMessage
can anyone help please...
private static void SendCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
String token = (string)e.UserState;
if (e.Cancelled)
{
Console.WriteLine("[{0}] Send canceled.", token);
}
if (e.Error != null)
{
MessageBox.Show(String.Format("[{0}] {1}", token, e.Error.ToString()));
}
else
{
Console.WriteLine("Message sent.");
}
mailSent = true;
}
private static void send_message()
{
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential("it@mydomain.com", "my_password");
client.EnableSsl = true;
MailAddress from = new MailAddress("it@mydomain.com", "My" + (char)0xD8 + " Company", System.Text.Encoding.UTF8);
MailAddress to = new MailAddress("jassim@mydomain.com");
MailMessage message = new MailMessage(from, to);
message.Body = "This is a test e-mail message sent by an application. ";
string someArrows = new string(new char[] { '\u2190', '\u2191', '\u2192', '\u2193' });
message.Body += Environment.NewLine + someArrows;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = "test message 1" + someArrows;
message.SubjectEncoding = System.Text.Encoding.UTF8;
client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userState = "test message1";
client.SendAsync(message, userState);
Console.WriteLine("Sending message... press c to cancel mail. Press any other key to exit.");
string answer = Console.ReadLine();
message.Dispose();
Console.WriteLine("Goodbye.");
}
private void btnSend_Click(object sender, EventArgs e)
{
if (XtraMessageBox.Show("Are you sure you want to send this message to all contacts now?", "Send", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
send_message();
}
}
Technology News @ www.JassimRahma.com
|
|
|
|
|
And, why haven't you inserted a break-point, and used F11 to single-step through the code and locate the error ?
«At the still point of the turning world. Neither flesh nor fleshless;
Neither from nor towards; at the still point, there the dance is
...
Neither ascent nor decline. Except for the point, the still point,
There would be no dance, and there is only the dance»
T.S. Elliot, The Four Quartets: "Burnt Norton"/xml>
|
|
|
|
|
I guess it is caused by the combination of
client.SendAsync(message, userState);
message.Dispose();
Because of the async part, that function returns immediately, though the process of sending may not even have started. But now you call Dispose on the message object which is still to be sent / being sent.
I suggest to remove the message.Dispose line.
|
|
|
|
|
The error is at
client.SendAsync(message, userState);
Console.WriteLine("Sending message... press c to cancel mail. Press any other key to exit.");
string answer = Console.ReadLine();
message.Dispose();
SendAsync does nothing else than sending the message asynchronously, meaning that at the point you dispose the message , the asynchrobnous send routine is still trying to access the message object. Leave away the dispose part, since the message is automatically disposed by the Garbage Collector once it isn't in use anymore.
The console is a black place
|
|
|
|
|
|
Read the forum posting guidelines here. This is not a question, and not appropriate for this forum.
«At the still point of the turning world. Neither flesh nor fleshless;
Neither from nor towards; at the still point, there the dance is
...
Neither ascent nor decline. Except for the point, the still point,
There would be no dance, and there is only the dance»
T.S. Elliot, The Four Quartets: "Burnt Norton"/xml>
|
|
|
|
|
Most barcode readers will return the barcode data in text form, so you don't need to do a lot of programming to work with them.
|
|
|
|
|
+5
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks. Amazing how many people ask how to program their reader before even investigating which one they are going to buy.
|
|
|
|
|
True. I remember years ago having to include support for a barcode reader and my initial thoughts were "Great, now I have to learn how to interface with another device." Turns out it just returned it as text to whatever control had focus.
Too easy. No coding required.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I am trying to get this VB code to a C# code, and I know I need to use ToString, but I cannot get the code to run correctly, it gives errors for everything. The code is a cartitem and its trying to get the quantity and adding the product price to it, here is what I have:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class CartItem
{
public Product Product;
public int Quantity;
public string Display()
{
return (Product.Name + (" ("
+ (Quantity.ToString() + (" at "
+ (FormatCurrency(Product.UnitPrice) + " each)")))));
}
}
|
|
|
|
|
Probably no for "everything".
C# does not have a "FormatCurrency" function. It does not have functions at all. You will have to find some C# way to format the unitprice.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You can format currency like this:
decimal value = -19230023.33M;
string format = string.Format("{0:C}", value);
|
|
|
|
|
You could create an extension method that returns the value formatted as a currency.
string currency = value.FormattedCurrency();
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
I could, but then again, I'm not the one asking the question
|
|
|
|
|
Oops let me re-post this to the OP
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
I HIGHLY suggest you read up on string.Format() . It'll make your life sooooo much easier than trying to figure out which quote marks pair up with which.
return string.Format("{0} ({1:N0} at {2:C2} each)", Product.Name, Quantity, Product.UnitPrice);
|
|
|
|
|
Exactly. And it is an important step for globalization / localization, as the order of words may be different in other languages.
|
|
|
|
|
You could create an extension method that returns the value formatted as a currency.
string currency = value.FormattedCurrency();
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
Hi there.
The .NET applications I provide for our test team are using the same set of assemblys. Depending on which test teams uses the app the corresponing assembly will be loaded at runtime.
Easy stuff. One must just handle the AppDomain.ResolveAssembly event properly and everything is fine. So when the app isn't able to resolve a type I simple check all loaded assemblys.
Doing that i came up with the idea, that if I cannot find a depended assembly it is properly because it is missing in the apps working directory. So I could copy it from our file server to the WD and simple load it.
With this mechanism I am able to roll out a new app simple by distributing the executable and on start the app will collect it's dependencies by itself.
Neat stuff. Worked fine for anything invovling WinddowsForms and WPF.
Now with console application the hole thing went kaputt.
Instead of any event being triggered the hole console application just crashed. NO UnhandledException even or any catch just a big kernel32 APPCRASH.
After a hole day of brainfuck, I found a solution but I don't get it.
Here is the thing:
Normally console applications aren't that big so the mayor coding stays in the main(string[] args) method.
Here is a constructed example:
public static void Main(string [ ] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler ( ConsoleExceptionHandler.CurrentDomain_UnhandledExceptionConsole);
AppDomain.CurrentDomain.AssemblyResolve += (AssemblyResolver.CurrentDomain_AssemblyResolve);
Console.WriteLine ( typeof ( JobData ).ToString () );
Console.WriteLine ( typeof ( TSExecTask ).ToString () );
Console.WriteLine ( typeof ( ReportingTask).ToString () );
Console.ReadLine ();
}
which does not work. But if I move the three Console.WriteLine in a separate class (ConsoleCrap) it works.
public static void Main(string [ ] args)
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler ( ConsoleExceptionHandler.CurrentDomain_UnhandledExceptionConsole);
AppDomain.CurrentDomain.AssemblyResolve += (AssemblyResolver.CurrentDomain_AssemblyResolve);
System.Threading.Thread.Sleep ( 100 );
new ConsoleCrap ().WriteSome ();
Console.ReadLine ();
}
I thought maybe, by postponing the point where the missing types are needed, the event has the nessesary time to collect the assemblys.
But the AsssemblyResolve event isn't asynchronous. So the actual execution flow is on hold while the type is not resolved.
On the other hand maybe the issue is, that by using the missing types directly the class containing the the static main() method cannot be laoded as it is missing the assembly before the AssemblyResolve event is registered.
So my question to all knowing more of coding then myself. (basically the rest of the universe)
Maybe someone si abel to givve ma some insight?
|
|
|
|
|
Console-applications come from the era of single-threading. There is no message-pump, so yes, it will be blocking. And yes, any types referenced in a method are loaded before the method is executed.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|