2
내 코드는 실제로 아무것도 인쇄하지 않고 .xps 파일을 저장하는 saveFileDialog를 생성합니다. 내 코드에 문제가 있습니까? 그렇지 않다면 어떻게이 코드가 작동하도록 컴퓨터를 구성 할 수 있습니까?내 인쇄 방법이 XPS 파일을 저장하지만 인쇄하지 않습니까?
class Printer {
public Printer() {
}
private void PrintDocument_PrintPage(Object sender, PrintPageEventArgs e) {
Font printFont = new Font("Courier New", 12);
e.Graphics.DrawString(StringToPrint, printFont, Brushes.Black, 0, 0);
}
private PrintDocument pd = new PrintDocument();
private string StringToPrint;
public void PrintString(string input) {
pd.PrintPage += new PrintPageEventHandler(PrintDocument_PrintPage);
StringToPrint = input;
pd.Print();
}
}
코드 :
Printer Printer = new Printer();
Printer.PrintString("Hello world");
그게 전부 였고 ... 코드 문제가 있다고 생각했습니다. – sooprise
기본값이 아닌 프린터를 사용하려는 경우에도 프린터를 지정할 수 있습니다. 몇 년 전에 pdf 프린터로 인쇄하려면이 작업을 수행해야했습니다. – Fry