473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PrintPreview?

Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but after
preview was shown, when i press the "print" button, i cannot print the
document although there is some words on the preview. So, is there a bug in
the preview?

Thanks...
Jan 2 '06 #1
11 2334
Adam,

Without seeing your code, it's impossible to say. You might have a bug
in your code.

Can you post a complete example?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but
after preview was shown, when i press the "print" button, i cannot print
the document although there is some words on the preview. So, is there a
bug in the preview?

Thanks...

Jan 2 '06 #2
Hi,

Hi,

My code is on the below,

m_PrintDocument = new PrintDocument( );
m_PrintDocument.PrintPage += new PrintPageEventHandler(
m_PrintDocument_PrintPage );
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog ( );
printPreviewDialog1.Document = m_PrintDocument;
Form m_Temp = ( Form ) printPreviewDialog1;
m_Temp.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog ( );

void m_PrintDocument_PrintPage( object sender, PrintPageEventArgs e )
{
Font printFont = new Font ( "Courier" , 10 , FontStyle.Regular );
String myString = "Trying";
e.Graphics.DrawString( myString, printFont, Brushes.Black, 0, 0, new
StringFormat( ) );
}

The printPreview dialog does not print my document although there are words
on the document.
Thanks..
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Adam,

Without seeing your code, it's impossible to say. You might have a bug
in your code.

Can you post a complete example?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but
after preview was shown, when i press the "print" button, i cannot print
the document although there is some words on the preview. So, is there a
bug in the preview?

Thanks...


Jan 2 '06 #3
Hi,

can you give your mail address. I want to send yo an attachment in which
there is a screen shot about this problem....

"Adam Right" <ad**@right.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
Hi,

Hi,

My code is on the below,

m_PrintDocument = new PrintDocument( );
m_PrintDocument.PrintPage += new PrintPageEventHandler(
m_PrintDocument_PrintPage );
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog ( );
printPreviewDialog1.Document = m_PrintDocument;
Form m_Temp = ( Form ) printPreviewDialog1;
m_Temp.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog ( );

void m_PrintDocument_PrintPage( object sender, PrintPageEventArgs e )
{
Font printFont = new Font ( "Courier" , 10 , FontStyle.Regular );
String myString = "Trying";
e.Graphics.DrawString( myString, printFont, Brushes.Black, 0, 0, new
StringFormat( ) );
}

The printPreview dialog does not print my document although there are
words on the document.
Thanks..
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Adam,

Without seeing your code, it's impossible to say. You might have a
bug in your code.

Can you post a complete example?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but
after preview was shown, when i press the "print" button, i cannot print
the document although there is some words on the preview. So, is there a
bug in the preview?

Thanks...



Jan 2 '06 #4
Adam,

You can post it here, and I will see it. No need to hide it from the
rest of the group.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:ey**************@TK2MSFTNGP11.phx.gbl...
Hi,

can you give your mail address. I want to send yo an attachment in which
there is a screen shot about this problem....

"Adam Right" <ad**@right.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
Hi,

Hi,

My code is on the below,

m_PrintDocument = new PrintDocument( );
m_PrintDocument.PrintPage += new PrintPageEventHandler(
m_PrintDocument_PrintPage );
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog ( );
printPreviewDialog1.Document = m_PrintDocument;
Form m_Temp = ( Form ) printPreviewDialog1;
m_Temp.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog ( );

void m_PrintDocument_PrintPage( object sender, PrintPageEventArgs e )
{
Font printFont = new Font ( "Courier" , 10 , FontStyle.Regular );
String myString = "Trying";
e.Graphics.DrawString( myString, printFont, Brushes.Black, 0, 0, new
StringFormat( ) );
}

The printPreview dialog does not print my document although there are
words on the document.
Thanks..
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Adam,

Without seeing your code, it's impossible to say. You might have a
bug in your code.

Can you post a complete example?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but
after preview was shown, when i press the "print" button, i cannot
print the document although there is some words on the preview. So, is
there a bug in the preview?

Thanks...



Jan 2 '06 #5
Nicholas,

I prepared a response for Adam, telling him that he was using
PrintDocument incorrectly. Then I read the "about PrintDocument"
documentation for the .NET Framework 1.1, and found that he was
following their instructions exactly. This let to a question:

Do you know whether PrintPreviewDialog, when you choose "Print..." from
the menu, re-uses the original instance of the PrintDocument you pass
it, or instantiates a new PrintDocument for the printing process
itself?

I ask because I've always inherited from PrintDocument and overridden
OnPrintPage, rather than handling the PrintPage event of a "vanilla"
PrintDocument. The former approach has always worked for me. However,
if PrintPreviewDialog instantiates a _new_ PrintDocument instance
internally in order to print, the latter method (the method recommended
by MS in its documentation) _won't_ work.

Jan 2 '06 #6
Hi,

Is there a basic solution for this problem, i cannot understand complex
english sorry...

"Bruce Wood" <br*******@canada.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Nicholas,

I prepared a response for Adam, telling him that he was using
PrintDocument incorrectly. Then I read the "about PrintDocument"
documentation for the .NET Framework 1.1, and found that he was
following their instructions exactly. This let to a question:

Do you know whether PrintPreviewDialog, when you choose "Print..." from
the menu, re-uses the original instance of the PrintDocument you pass
it, or instantiates a new PrintDocument for the printing process
itself?

I ask because I've always inherited from PrintDocument and overridden
OnPrintPage, rather than handling the PrintPage event of a "vanilla"
PrintDocument. The former approach has always worked for me. However,
if PrintPreviewDialog instantiates a _new_ PrintDocument instance
internally in order to print, the latter method (the method recommended
by MS in its documentation) _won't_ work.

Jan 2 '06 #7
I have a potential solution, but it will have to wait until tomorrow,
when I will be back in the office and will have a printer with which to
test.

I want to write a little test program to discover whether my theory is
correct.

Jan 2 '06 #8
Adam,
Since you are putting the text at 0,0 on the page you may be outside the
'hard margin' of the printer and thus not printing anything. Try it again
with 100, 100 which should be 1" down and 1" right from the page edge using
the standard coordinates. Alternately you could try setting OriginAtMargins
to true for the PrintDocument (I think).

Ron Allen
"Adam Right" <ad**@right.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
Hi,

Hi,

My code is on the below,

m_PrintDocument = new PrintDocument( );
m_PrintDocument.PrintPage += new PrintPageEventHandler(
m_PrintDocument_PrintPage );
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog ( );
printPreviewDialog1.Document = m_PrintDocument;
Form m_Temp = ( Form ) printPreviewDialog1;
m_Temp.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog ( );

void m_PrintDocument_PrintPage( object sender, PrintPageEventArgs e )
{
Font printFont = new Font ( "Courier" , 10 , FontStyle.Regular );
String myString = "Trying";
e.Graphics.DrawString( myString, printFont, Brushes.Black, 0, 0, new
StringFormat( ) );
}

The printPreview dialog does not print my document although there are
words on the document.
Thanks..
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Adam,

Without seeing your code, it's impossible to say. You might have a
bug in your code.

Can you post a complete example?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but
after preview was shown, when i press the "print" button, i cannot print
the document although there is some words on the preview. So, is there a
bug in the preview?

Thanks...



Jan 3 '06 #9
Hi Ron,

I have tried that but the printed document still is empty. I do not
understand that if there are some words on the preview, what is the reason
that it does not print that words? in Beta 2, i can print with the same
code. So i am wondering about Framework 2.0 in which there may be a bug in
print document. I do not know how can i handle that problem, because it is
very important for me and my customers. Thanks...

"Ron Allen" <Ro******@newsgroups.nospam> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
Adam,
Since you are putting the text at 0,0 on the page you may be outside
the 'hard margin' of the printer and thus not printing anything. Try it
again with 100, 100 which should be 1" down and 1" right from the page
edge using the standard coordinates. Alternately you could try setting
OriginAtMargins to true for the PrintDocument (I think).

Ron Allen
"Adam Right" <ad**@right.com> wrote in message
news:Ox**************@TK2MSFTNGP14.phx.gbl...
Hi,

Hi,

My code is on the below,

m_PrintDocument = new PrintDocument( );
m_PrintDocument.PrintPage += new PrintPageEventHandler(
m_PrintDocument_PrintPage );
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog ( );
printPreviewDialog1.Document = m_PrintDocument;
Form m_Temp = ( Form ) printPreviewDialog1;
m_Temp.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog ( );

void m_PrintDocument_PrintPage( object sender, PrintPageEventArgs e )
{
Font printFont = new Font ( "Courier" , 10 , FontStyle.Regular );
String myString = "Trying";
e.Graphics.DrawString( myString, printFont, Brushes.Black, 0, 0, new
StringFormat( ) );
}

The printPreview dialog does not print my document although there are
words on the document.
Thanks..
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Adam,

Without seeing your code, it's impossible to say. You might have a
bug in your code.

Can you post a complete example?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Adam Right" <ad**@right.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using .Net Framework 2.0 final, and i use .Net printing library to
print a document. I use printPreview dialog to print the document but
after preview was shown, when i press the "print" button, i cannot
print the document although there is some words on the preview. So, is
there a bug in the preview?

Thanks...



Jan 3 '06 #10
I ran my little test using .NET 1.1, and I was wrong. Ron Allen's
solution is most likely the correct one.

In my case, your code, as written, works fine in print preview and when
printing from print preview. No problems at all in .NET 1.1.

I'm not using .NET 2.0, so I'll leave it to others to try to reproduce
this behaviour in 2.0.

Jan 3 '06 #11
OK, I had to try this here. The following works for me here using VS2005
both in preview mode and in printer output (although I haven't checked for
any hard margin offsets). Note that I've used a stock StringFormat object
and disposed of the Font created. I'm using a Lexmark Optra printer but I
don't think that the printer should make a difference. All my variable are
local as well.

Ron Allen
----------------------------snippet---------------------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
PrintDocument m_PrintDocument = new PrintDocument();
m_PrintDocument.PrintPage += new
PrintPageEventHandler(m_PrintDocument_PrintPage);
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
printPreviewDialog1.Document = m_PrintDocument;
printPreviewDialog1.WindowState = FormWindowState.Maximized;
printPreviewDialog1.ShowDialog();
printPreviewDialog1.Dispose();
}

void m_PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
Font printFont = new Font("Courier", 10, FontStyle.Regular);
String myString = "Trying";
e.Graphics.DrawString(myString, printFont, Brushes.Black, 100, 100,
StringFormat.GenericDefault);
printFont.Dispose();
}

----------------------------snippet---------------------------------------------------------
"Adam Right" <ad**@right.com> wrote in message
news:ec**************@TK2MSFTNGP14.phx.gbl...
Hi Ron,

I have tried that but the printed document still is empty. I do not
understand that if there are some words on the preview, what is the reason
that it does not print that words? in Beta 2, i can print with the same
code. So i am wondering about Framework 2.0 in which there may be a bug in
print document. I do not know how can i handle that problem, because it is
very important for me and my customers. Thanks...

Jan 3 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LARB | last post by:
Good morning, I have a print routine where I use a "printpreview dialog' control. The text is perfect BUT when I then print the job all the text is completely crazy, a bit like...
1
by: Randy | last post by:
Hello, I'm trying to print a simple string using the PrintPreviewDialog. I get the string to show up in the PrintPreview dialog, but when I click the Printer icon, it just prints a blank page....
0
by: sachin | last post by:
When we view any document in print preview dialog, where does it save the document? such that when me move to next/previous page where it reads the information from . If a heavy document like RTF...
1
by: Dev2004 | last post by:
Hello, Does anyone have any examples on how I could show the contents of the TreeView in a PrintPreview window. I've looked at the PrintPreviewDialog control but could not see how I could link...
9
by: Adam Right | last post by:
Hi, I am using .Net Framework 2.0 final, and i use .Net printing library to print a document. I use printPreview dialog to print the document but after preview was shown, when i press the...
0
by: james | last post by:
While trying to help another programmer on MSDN's Visual Basic 2005 Express Edition forum, he (and I ) ran into a strange problem with the PrintPreview Control in VB2005. If you load a document (...
0
by: Joxie | last post by:
Hi, All! Recently I'm using ultrawebgrid for my projects... While I try Ultragrid (for windows application) I could call printpreview as ultragrid function, but while I'm using Ultrawebgrid (for...
6
by: Stuart Nathan | last post by:
Can someone tell me how to remove a previously loaded PrintDocument in a PrintPreview control, so that I can display a nedw one?
2
by: eBob.com | last post by:
I have a print application modeled on a program which I found via this newsgroup. (I still have comments in German in it!) The model uses ExtendedPrintPreviewDialog but I don't seem to have that...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.