简体   繁体   中英

C# Printing A Form

I'm new to c#, so I hope this doesn't sound/look stupid.

I'm having an issue while printing. I can't seem to get my form to print on the full size of a regular piece of paper. It's printing in landscape, the height fits, but my width goes off the page. Here is the code I'm working with.

Any help would be greatly appreciated, thanks!

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.DrawImage(memoryImage, 0, 0);
}

private void printPreviewDialog1_Load(object sender, EventArgs e)
{
    PrintPreviewDialog _PrintPreview = new PrintPreviewDialog();
    _PrintPreview.Document = printDocument1;
    ((Form)_PrintPreview).WindowState = FormWindowState.Normal;
    _PrintPreview.ShowDialog();
}

private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
    SaveAsBitmap(this, @"img\1.bmp");
    CaptureScreen();
    printDocument1.PrinterSettings.DefaultPageSettings.Landscape = true;
    printDocument1.Print();
}

try setting the papersize in the printOption : http://msdn.microsoft.com/en-us/library/aa691030(v=vs.71).aspx

Hope this can help you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM