我有一个要打印的自定义控件。我已经尝试更改窗口上的边距以“缩进”我的控件,但它仍然切断了左侧和顶部。我还在打印方法中尝试了以下方法:
private void bttnPrint_Click(object sender, RoutedEventArgs e)
{
UserControl hddc = HDDC;
var printDlg = new PrintDialog
{PrintTicket = {PageOrientation = PageOrientation.Landscape, PageBorderless = PageBorderless.Unknown}};
//printDlg.PrintTicket.PageMediaSize.PageMediaSizeName = PageMediaSizeName.NorthAmerica11x17;
if (printDlg.ShowDialog() == true)
{
printDlg.PrintVisual(hddc, "HDDC Report");
}
else
{
MessageBox.Show("Print Canceled");
}
}
仍然,没有快乐。我觉得我缺少一个愚蠢的设置,但我似乎无法找到它。为什么我的打印在顶部和左侧被切断?
最佳答案
public void Printing() {
try {
streamToPrint = new StreamReader (filePath);
try {
PrintDocument prd = new PrintDocument();
prd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
prd.PrinterSettings.PrinterName = printer;
// Set the page orientation to landscape.
prd.DefaultPageSettings.Landscape = true;
prd.Print();
}
finally {
streamToPrint.Close() ;
}
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
}
}
命名空间:System.Drawing.Printing
或者也许这个链接可以帮助你 Page truncate in right side for landscape orientation with trimmargins using PdfSharp
关于c# - 打印用户控件在顶部和左侧切掉半英寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18389953/