3

我有一个正在尝试打印的自定义控件。我尝试将窗口上的边距更改为“缩进”我的控件,但它仍然切断了左侧和顶部。我还在我的打印方法中尝试了以下内容:

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

尽管如此,还是没有喜悦。我有一种感觉,我错过了一个愚蠢的设置,但我似乎无法找到它。为什么我的打印在顶部和左侧被切断?

4

1 回答 1

0
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

或者也许这个链接可以帮助你 在右侧截断页面以使用 PdfSharp 进行横向修剪

于 2013-11-12T16:26:53.017 回答