我创建了一个允许用户打印多个jpg文件的应用程序。所以我直接发送我的打印请求,如下所示:
if (existfile == true)
{
PrinterSettings a=new PrinterSettings();
PrintDocument pd = new PrintDocument();
IEnumerable<PaperSize> size = a.PaperSizes.Cast<PaperSize>();
PaperSize a4 = size.First<PaperSize>(i => i.Kind == PaperKind.A4);
pd.DefaultPageSettings.Landscape = true;
pd.DefaultPageSettings.PaperSize = a4;
pd.PrintPage += PrintPage;
pd.Print();
}
打印功能:
private void PrintPage(object o, PrintPageEventArgs e)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(CurrentAddress);
Point loc = new Point(100, 100);
e.Graphics.DrawImage(img, loc);
}
但是这段代码只打印了我图像的某些部分,而不是全部。我想打印它们scale to fit
。我怎么能这样做?
答案 0 :(得分:0)
这可能会解决问题。
e.Graphics.DrawImage(img, e.MarginBounds);
或
e.Graphics.DrawImage(img, e.PageBounds);
或
ev.Graphics.DrawImage(Image.FromFile("C:\\My Folder\\MyFile.bmp"), ev.Graphics.VisibleClipBounds);