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.PrintDocument {
// Current page
private int currentPage = 1;
// Total pages
private int totalPages = 2;
private System.Drawing.SolidBrush brush1 = new
System.Drawing.SolidBrush(System.Drawing.Color.Black);
private System.Drawing.Font font1 = new System.Drawing.Font("Arial",
42.48F, ((System.Drawing.FontStyle)(0)), System.Drawing.GraphicsUnit.Point,
1);
private System.Drawing.StringFormat stringformat1 = new
System.Drawing.StringFormat(System.Drawing.StringFormat.GenericTypographic);
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.InitializeGraphics();
}
private void InitializeGraphics() {
this.stringformat1.Alignment = System.Drawing.StringAlignment.Near;
}
protected override void
OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) {
System.Drawing.Graphics g = e.Graphics;
this.printGraphics(g);
if ((this.currentPage < this.totalPages)) {
e.HasMorePages = true;
this.currentPage = (this.currentPage + 1);
}
else {
e.HasMorePages = false;
}
}
// Required to dispose of created resources
private void DisposeGraphics() {
this.brush1.Dispose();
this.font1.Dispose();
this.stringformat1.Dispose();
}
protected override void Dispose(bool disposing) {
if (disposing) {
this.DisposeGraphics();
}
}
private void printGraphics(System.Drawing.Graphics g) {
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.TextRenderingHint =
System.Drawing.Text.TextRenderingHint.AntiAlias;
if ((this.currentPage == 1)) {
g.DrawString(this.Text3, this.font1, this.brush1,
this.Text3Rect, this.stringformat1);
g.DrawString(this.Text5, this.font1, this.brush1,
this.Text5PointX, this.Text5PointY);
}
if ((this.currentPage == 2)) {
g.DrawString(this.Text6, this.font1, this.brush1,
this.Text6PointX, this.Text6PointY);
}
}
}