Anonymousaaaaaaaaaaaaaaaahhhh

ello i just want to know what im doing wrong basicly this print previews to the screen and prints, i can set my bitmap image to a select size but for some reason i can increase the size of the actual image, so when im in print preview i get a small form what i want to increase and a big black box what the bmp that iv created, i want the form to be the same size as the bmp whats bout half the page but the size at the min is like a thumb nail!

private void cmdPrint_Click(object sender, EventArgs e)

{

PrintDocument doc = new PrintDocument();

doc.PrintPage += this.printDocument1_PrintPage;

PrintDialog dlgSettings = new PrintDialog();

dlgSettings.Document = doc;

try

{

string strText = this.txtsave.Text; // read string from editor window

PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog(); // instantiate new print preview dialog

this.printPreviewDialog1.Document = this.printDocument1;

this.printPreviewDialog1.ShowDialog(); // Show the print preview dialog, uses print page event to draw preview screen

}

catch (Exception exp)

{

System.Console.WriteLine(exp.Message.ToString());

}

if (dlgSettings.ShowDialog() == DialogResult.OK)

{

printDocument1.Print();

}

}

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)

{

Font font = new Font("Arial", 30);

float x = e.MarginBounds.Left;

float y = e.MarginBounds.Top;

float lineHeight = font.GetHeight(e.Graphics);

for (int i = 0; i < 5; i++)

{

e.Graphics.DrawString(txtsave.Text.ToString(), font, Brushes.Black, x, y);

y += lineHeight;

}

y += lineHeight;

Bitmap bmp = new Bitmap(4900, 3000);

e.Graphics.CopyFromScreen(0, 0, 100, 100, bmp.Size);

}

thanx in advance!



Re: Visual C# Express Edition printing(bmp image not increasing in size??)

JohnWein

I think what you want to do is capture the screen to a bitmap and then print it. Is that correct

Is your screen really 4900 x 3000 pixels





Re: Visual C# Express Edition printing(bmp image not increasing in size??)

Anonymousaaaaaaaaaaaaaaaahhhh

lol, well iv sorted the problem out. thats not the screen size but the size to be printed on paper 1024 , 768 is very small on paper! here is the code below! my mistake in what i did was bliting to a picturebox then blit that to the printer, instead i blit it to the grahics .g and the blit that to the graphics to the printer grahics and scale to the size that i want to print what 0.9F, (1.0F is full size of paper portrait).

private void cmdPrint_Click(object sender, EventArgs e)

{

PrintDocument doc = new PrintDocument();

doc.PrintPage += this.printDocument1_PrintPage;

PrintDialog dlgSettings = new PrintDialog();

dlgSettings.Document = doc;

try

{

string strText = this.txtsave.Text; // read string from editor window

PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog(); // instantiate new print preview dialog

this.printPreviewDialog1.Document = this.printDocument1;

//this.printPreviewDialog1.Scale();

this.printPreviewDialog1.ShowDialog(); // Show the print preview dialog, uses print page event to draw preview screen

}

catch (Exception exp)

{

System.Console.WriteLine(exp.Message.ToString());

}

if (dlgSettings.ShowDialog() == DialogResult.OK)

{

printDocument1.Print();

}

}

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)

{

Font font = new Font("Arial", 30);

float x = e.MarginBounds.Left;

float y = e.MarginBounds.Top;

float lineHeight = font.GetHeight(e.Graphics);

for (int i = 0; i < 5; i++)

{

e.Graphics.DrawString(txtsave.Text.ToString(), font, Brushes.Black, x, y);

y += lineHeight;

}

y += lineHeight;

Bitmap bmp = new Bitmap(800, 600);

e.Graphics.ScaleTransform(0.9f, 0.9f);

DrawTheGraph(e.Graphics);

// e.Graphics.CopyFromScreen(0, 25, 100, 100, bmp.Size);

e.Graphics.Dispose();

}

private void panel4_Paint(object sender, PaintEventArgs e)

{

Graphics g = e.Graphics;

//make the raster graphics smooth round the edges (shading)

e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

e.Graphics.TranslateTransform(150, 150);

e.Graphics.RotateTransform(270);

Font fnt = new Font("Verdana", 16);

e.Graphics.DrawString("GDI+ World", fnt, new SolidBrush(Color.Red), 14, 10);

e.Graphics.ResetTransform();

}

}