printing spansih characters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone,

I have to get a string from the database and print it directly to the
printer wihout a print confirmation box. How can I do this in C# windows
application.

Thanks.
 
At the most basic level, create a PrintDocument and Print() it. Note
that you can't print (without user input) under some trust settings
(unsigned internet app, for instance) - but it should be fine if the
app is installed locally or signed for ClickOnce.

http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx
http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printingpermissionlevel.aspx

Other print tools are available, but using PrintDocument:

private void PrintSomething() {
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print();
}

void pd_PrintPage(object sender, PrintPageEventArgs e) {
e.HasMorePages = false;
string gigo = @"Respetados Señores, (Estimados Señores)
Hemos recibido su carta del ...";
e.Graphics.DrawString(gigo, SystemFonts.DefaultFont,
SystemBrushes.WindowText, new PointF(0, 0));
}

Marc
 
(if getting data from the database is an issue, you'd need to be a bit
more specific about your setup, as there dozens of ways to do this...)

Marc
 
Hi Marc,

Thanks for your response. I created a table and I have spansih data in that
table. In ASP.net site, I will get the spanish data string in executeScalar
because that's the only string present in the table. Once I have the string
in string type varaible, I want that string to be printed directly to the
database right after I read the string from the database.



Thanks
 
In ASP.net site...
Please can you clarify where exactly you want this text to be printed?
Your original question related to a "c# windows application" -
however, this will work /completely/ differently to ASP.NET
Once I have the string in string type varaible, I want that string to be printed directly to the
database right after I read the string from the database.
By this, do you mean at the server? Or back at the client (in which
case it can't be "right after")...

If you mean you want the user's browser to silently print a page, then
you can't really do this under the HTML model [nothing to do
with .NET] unless you cheat and use a control of some kind. The best
you can do is bring up the print dialog, by calling window.Print() (in
javascript) at the client.

Marc
 
Hi Marc,


I can print the string directly to the prnter. Thanks for your help.




Marc Gravell said:
In ASP.net site...
Please can you clarify where exactly you want this text to be printed?
Your original question related to a "c# windows application" -
however, this will work /completely/ differently to ASP.NET
Once I have the string in string type varaible, I want that string to be printed directly to the
database right after I read the string from the database.
By this, do you mean at the server? Or back at the client (in which
case it can't be "right after")...

If you mean you want the user's browser to silently print a page, then
you can't really do this under the HTML model [nothing to do
with .NET] unless you cheat and use a control of some kind. The best
you can do is bring up the print dialog, by calling window.Print() (in
javascript) at the client.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top