[英]How to print bitmap image on the full size of the paper
I am currently creating a bitmap of 1632x1056 (17x11 at 96 dpi) pixels. 我目前正在创建1632x1056(96 dpi时为17x11)像素的位图。 I want to print this image on an 11in x 17in paper.
我想将此图像打印在11英寸x 17英寸的纸张上。
I can open this file up in Windows Photo Viewer and print it perfectly, but when I use the print function in c#, there is always a small margin that appears so it shifts my image to not fit on the whole page. 我可以在Windows Photo Viewer中打开该文件并将其完美打印,但是当我在c#中使用打印功能时,总是会出现一个很小的空白,因此它会将我的图像移动到不适合整个页面的位置。 This is my code settings for the print document
这是我对打印文档的代码设置
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;
}
I think the problem might be that the hardmargin values are set by the printer, and the values are 25 for hardmarginx and 16 for hardmarginy. 我认为问题可能是打印机设置了硬边距值,对于hardmarginx,值为25;对于硬边距,值为16。 Is there a way to set these to zero so that is the no margin offset when I print?
有没有办法将这些设置为零,以便在打印时没有页边距偏移? Thanks!
谢谢!
It appears you are not using the PageBorderless property. 看来您没有使用PageBorderless属性。 Try using the property as indicated in the MSDN documentation.
尝试使用MSDN文档中指示的属性。
Let me know if the problem persists. 让我知道问题是否仍然存在。
There's a reason why printers set a hard margin. 打印机设置硬边距是有原因的。 For some printers, they really mean it.
对于某些打印机,它们确实是真的。
For laser printers in particular, there's usually a signal for page top detect from the engine and the controller for the printer will get that and carefully time when to start lighting up the video circuitry (seriously - it's called video circuitry because it works the same as a CRT display) and write a charge onto the paper. 特别是对于激光打印机,通常会从引擎发出一个用于页面顶部检测的信号,并且打印机的控制器会获取该信号,并仔细计时何时开始点亮视频电路(严重的是,它被称为视频电路,因为它的工作原理与CRT显示屏),然后在纸上写上电荷。 Start too soon and you are hitting the internals for the first scanline.
太早开始,您将触及第一条扫描线的内部。 Scanlines are written by scanning the beam over the page and feeding the output of a FIFO into the beam control circuitry.
通过在页面上扫描光束并将FIFO的输出馈送到光束控制电路中来写入扫描线。 There is only so much area that the beam can cover on the paper and it has a hard limit.
只有这么多的区域,光束可以覆盖在纸张上,并且有一个硬限制。 You can't change it.
您无法更改。
Ink jet printers can do pretty well L/R on a page but there are often mechanical reasons why they can't manage T/B as the paper may (for example) not be held firmly enough to the platen to spray ink onto the top 3 mm or so. 喷墨打印机可以在页面上很好地进行左右比对,但是由于机械原因(例如)纸张可能没有牢固地固定在压板上而无法将墨水喷到顶部,所以经常有机械原因导致它们无法处理左右比。 3毫米左右。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.