471,316 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 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 2239
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Randy | last post: by
reply views Thread by sachin | last post: by
1 post views Thread by Dev2004 | last post: by
9 posts views Thread by Adam Right | last post: by
reply views Thread by james | last post: by
6 posts views Thread by Stuart Nathan | last post: by
reply views Thread by rosydwin | last post: by

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.