[英]Using graphics to draw rectangle at top left corner of WinForms control cuts off one pixel of top and left of rectangle
[英]Printing user control cuts off half an inch on top and left
我有一個我想要打印的自定義控件。 我已經嘗試更改窗口上的邊距以“縮進”我的控件,但它仍然會切斷左側和頂部。 我也在我的打印方法中嘗試了以下內容:
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
或者這個鏈接可以幫助你使用PdfSharp在右側進行橫向截斷,使用trimmargins
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.