【发布时间】:2014-09-04 20:03:00
【问题描述】:
我目前正在创建一个 1632x1056(17x11,96 dpi)像素的位图。我想在 11 英寸 x 17 英寸的纸上打印这张图片。
我可以在 Windows 照片查看器中打开这个文件并完美地打印它,但是当我在 c# 中使用打印功能时,总是会出现一个小的边距,所以它会使我的图像无法适应整个页面。 这是我打印文档的代码设置
Image glControlBits;
private void PrintImage()
{
//print the document
PrintDocument pd = new PrintDocument();
pd.PrintPage += pd_PrintPage;
pd.DefaultPageSettings.PaperSize = new PaperSize("PDI", 1100, 1700);
pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
pd.DefaultPageSettings.Landscape = true;
pd.OriginAtMargins = true;
//pd.DefaultPageSettings.PrintableArea = new RectangleF(0, 0, viewSize.X, viewSize.Y);
//pd.DefaultPageSettings.HardMarginX = 0;
//pd.DefaultPageSettings.HardMarginY = 0;
//pd.DefaultPageSettings.PrinterResolution
PrintDialog pdialog = new PrintDialog();
pdialog.Document = pd;
if (pdialog.ShowDialog() == DialogResult.OK)
{
//set the print image to be the bitmap of the glcontrol
glControlBits = GrabScreenshot();
//save the bitmap, for debugging purposes
glControlBits.Save(@"C:\Users\Shane\Desktop\testbitmap.bmp");
pd.Print();
}
else return;
}
我认为问题可能是硬边距值由打印机设置,硬边距值为 25,硬边距值为 16。有没有办法将这些设置为零,这样我打印时就没有边距偏移?谢谢!
【问题讨论】: