473,700 Members | 2,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PrintPreviewDia log Print Icon not printing

Hello all,
I'm trying to print using PrintPreviewDia log. What's happening is that the
PrintPreviewDia log shows the correct information to be printed, but when I
click the print icon, it prints a blank page. If I comment out the
printPreviewDia log1.ShowDialog ();
and just do a
printDocument1. Print();
instead, it prints all the pages like a champ. Anyone know what I'm doing
wrong?
Thanks
Nov 15 '05 #1
2 5865
Randy,
As I said in my earlier reply you aren't resetting the start of the
print data stream (or wherever you get your print data from). You should
override the OnBeginPrint method of the PrintDocument and set your stream's
staring position back to the beginning there. If you have read through the
stream once already and don't reset the position when you press on the print
button on the PrintPreviewDia log you will already be at the end and thus
have nothing available to print.

Ron Allen
"Randy" <te**@temp.co m> wrote in message
news:OF******** *****@TK2MSFTNG P11.phx.gbl...
Hello all,
I'm trying to print using PrintPreviewDia log. What's happening is that the
PrintPreviewDia log shows the correct information to be printed, but when I
click the print icon, it prints a blank page. If I comment out the
printPreviewDia log1.ShowDialog ();
and just do a
printDocument1. Print();
instead, it prints all the pages like a champ. Anyone know what I'm doing
wrong?
Thanks

Nov 15 '05 #2
Try this print document class. Made it with my new tool.

I did exactly what you said - showed a print dialogue and hit the print
button and it's ok. If you're a VB developer, let me know and I'll reexport
it in VB.

//Code starts here

// GDIPlus Architect PrintDocument Class Output
// www.mrgsoft.com
public class Untitled1 : System.Drawing. Printing.PrintD ocument {

// Current page
private int currentPage = 1;

// Total pages
private int totalPages = 2;

private System.Drawing. SolidBrush brush1 = new
System.Drawing. SolidBrush(Syst em.Drawing.Colo r.Black);

private System.Drawing. Font font1 = new System.Drawing. Font("Arial",
42.48F, ((System.Drawin g.FontStyle)(0) ), System.Drawing. GraphicsUnit.Po int,
1);

private System.Drawing. StringFormat stringformat1 = new
System.Drawing. StringFormat(Sy stem.Drawing.St ringFormat.Gene ricTypographic) ;

protected string Text3 = "Hello world";

private System.Drawing. RectangleF Text3Rect = new
System.Drawing. RectangleF(136, 128, 426, 88);

protected string Text5 = "page 1";

private System.Single Text5PointX = 130;

private System.Single Text5PointY = 222;

protected string Text6 = "page 2";

private System.Single Text6PointX = 130;

private System.Single Text6PointY = 222;

public Untitled1() {
this.Initialize Graphics();
}

private void InitializeGraph ics() {
this.stringform at1.Alignment = System.Drawing. StringAlignment .Near;
}

protected override void
OnPrintPage(Sys tem.Drawing.Pri nting.PrintPage EventArgs e) {
System.Drawing. Graphics g = e.Graphics;
this.printGraph ics(g);
if ((this.currentP age < this.totalPages )) {
e.HasMorePages = true;
this.currentPag e = (this.currentPa ge + 1);
}
else {
e.HasMorePages = false;
}
}

// Required to dispose of created resources
private void DisposeGraphics () {
this.brush1.Dis pose();
this.font1.Disp ose();
this.stringform at1.Dispose();
}

protected override void Dispose(bool disposing) {
if (disposing) {
this.DisposeGra phics();
}
}

private void printGraphics(S ystem.Drawing.G raphics g) {
g.SmoothingMode = System.Drawing. Drawing2D.Smoot hingMode.AntiAl ias;
g.TextRendering Hint =
System.Drawing. Text.TextRender ingHint.AntiAli as;
if ((this.currentP age == 1)) {
g.DrawString(th is.Text3, this.font1, this.brush1,
this.Text3Rect, this.stringform at1);
g.DrawString(th is.Text5, this.font1, this.brush1,
this.Text5Point X, this.Text5Point Y);
}
if ((this.currentP age == 2)) {
g.DrawString(th is.Text6, this.font1, this.brush1,
this.Text6Point X, this.Text6Point Y);
}
}
}

"Randy" <te**@temp.co m> wrote in message
news:OF******** *****@TK2MSFTNG P11.phx.gbl...
Hello all,
I'm trying to print using PrintPreviewDia log. What's happening is that the
PrintPreviewDia log shows the correct information to be printed, but when I
click the print icon, it prints a blank page. If I comment out the
printPreviewDia log1.ShowDialog ();
and just do a
printDocument1. Print();
instead, it prints all the pages like a champ. Anyone know what I'm doing
wrong?
Thanks

Nov 15 '05 #3

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

Similar topics

3
2560
by: Ramsey Schaffnit | last post by:
Context: I have to print personal information on a preprinted form I've never seen using a printer I've never seen. I want to use a control to overlay the PrintPreview to indicate where I've printed. I want to use a separate control in order to allow the user to drag the field to a different position on the form so it doesn't have to come back for me to change the code. I want to use the PrintPreview because it fits so naturally with...
1
1959
by: georg | last post by:
Hi, i have a problem with the PrintPreviewDialog, if i want to print out my document with the button in the preview dialog, the output on the printer is empty, but on the preview I can see it. If there is not more than one page it seems to work. Printing out without preview works correct. Could anybody please help me!?
0
1593
by: Harry J. Smith | last post by:
I am using the PrintPreviewDialog Window Form from the Toolbox. It displays my RichTextBox contents correctly, but when I click on the Print icon on this form it prints one blank page and no text. How can I fix this to print the text that is being displayed? Here is the code I use to bring up the form: string stringText = helpTextOut.Text;
1
2918
by: gabriel | last post by:
Hi all, I've got a problem with a PrintPreviewDialog. It shows my document correctly but when I try to print I only get the last page. Now when I use the print function of my document directly it print's correctly. I've overriden the OnPrintPage function of PrintDocument and for as far as I can see I've correctly set he HasMorePages property. Does anyone have an idea on how to fix this, or what I'm forgetting.
1
5698
by: Darrell Wesley | last post by:
Is there anyway to hook the PrintDialog to the printer icon on the PrintPreviewDialog? I know that you can print a document using the PrintDialog but it does not allow previewing and the PrintPreview dialog does not allow you to select a printer - is there a good and simple way to get around these problems. My users would like to select a specific printer while looking at the Preview window.
10
15311
by: choupi | last post by:
Hello, Is there a way to call a printDialog from a printPreviewDialog (from print icon for example)? Indeed, the print icon in the printpreviewdialog prints directly the document without lunching the printdialog (i.e. the user can't choose the print parameters). Thanks a lot.
0
1125
by: tim8w | last post by:
I have the following PrintPreviewDialog code: Code: Private Sub tsbPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbPrintPreview.Click Dim PrintPreviewJournalEntry As New PrintPreviewDialog document.DocumentName = CreateTmpRTFFile(rtfJournal) PrintPreviewJournalEntry.Document = document
0
1216
by: sunny123 | last post by:
How Can i set the print icon in the printpreviewdialog to go to the printdialog? when I click on Report button in my application it'll open the report in print preview screen. There when I click the print icon it will directly send the report to the printer. Before report send to the printer i want to give the option for selecting printer by showing print dialog. This is very urgent please help me. Thanks in advance
0
1225
by: mudapa03 | last post by:
In my application when I click on Report button report opens in Print Preview mode and when I click on print icon report directly send to the printer. Instead of that can I override the print icon to open Print Dialog box to give option to the user to select a printer. Please help me on this. This is very urgent. Thanks in advance.
0
8731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8975
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7819
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4660
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3097
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2032
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.