473,544 Members | 1,739 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 5851
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
2539
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...
1
1924
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
1576
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 =...
1
2906
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...
1
5686
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...
10
15293
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
1113
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
1205
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...
0
1214
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
7416
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...
0
7360
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7761
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...
1
7363
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...
0
7701
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5899
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...
1
5289
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...
0
4906
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1833
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

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.