【问题标题】:PrintDocument just prints some part of my JPG filePrintDocument 只是打印我的 JPG 文件的一部分
【发布时间】:2016-10-26 09:05:25
【问题描述】:

我创建了一个允许用户打印多个 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。我该怎么做?

【问题讨论】:

  • - 使用具有两个矩形的 DrawImage 重载。一个用于源,另一个用于目的地。后者可用于缩放图像。
  • Point loc = new Point(0, 0);
  • @TaW 你能告诉我更多细节吗?

标签: c# printing printdocument


【解决方案1】:

这可能会解决问题。

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);

【讨论】:

  • 让我检查一下
  • 它可以工作,但我在下面的图片中只有一个大约 2 或 3 厘米的问题丢失了
  • 我用这个:e.Graphics.DrawImage(img, e.PageBounds);
  • 试试MarginBounds看看结果。
  • 我用过,但是图片打印的太小了,不适合
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多