I am trying to allow my users to print the current page they are on in our WinForm program. First I take a screenshot of the app and save it to disk. Then I kick off a PrintPreviewDialog
and load it in there.
That all works, except for the fact that it goes off the page! I can't figure out how to change or allow the user to change the page layout for printing to landscaped and/or to "auto fit" the screenshot to 1 page.
private void printDetailsToolStripMenuItem_Click(object sender, EventArgs e)
{
HUD.ShellForm.SaveAsImage("CaseNoteDetails.jpg", ImageFormat.Jpeg);
printPreviewDialog1.PrintPreviewControl.AutoZoom = true;
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.AutoSize = true;
printPreviewDialog1.ShowDialog();
}
void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;
e.Graphics.DrawImage(Image.FromFile("c:\\CaseNoteDetails.jpg"), x, y);
}
I changed one line to this -->
e.Graphics.DrawImage(Image.FromFile("c:\\CaseNoteDetails.jpg"), x, y,1000,750);
and that works except I have almost 1/3 of the printed page as white space. How do I minimize the Padding/Margins so I can use the whole page?