Hallo Zusammen,
da mir bei meinem letzten Problem so grandios geholfen wurde, nochmals vielen Dank.
Wende ich mich erneut an euch.
Habe folgenden Code im Internet gefunden um mehrere Dokumente auf einmal auszudrucken:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66:
| public class MultiPrintDocument : PrintDocument { private PrintDocument[] _documents; private int _docIndex; private PrintEventArgs _args;
public MultiPrintDocument(PrintDocument document1, PrintDocument document2) { _documents = new PrintDocument[] { document1, document2 }; }
public MultiPrintDocument(PrintDocument[] documents) { _documents = documents; }
protected override void OnBeginPrint(PrintEventArgs e) { base.OnBeginPrint(e); if (_documents.Length == 0) e.Cancel = true;
if (e.Cancel) return;
_args = e; _docIndex = 0; CallMethod(_documents[_docIndex], "OnBeginPrint", e); }
protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e) { e.PageSettings = _documents[_docIndex].DefaultPageSettings; CallMethod(_documents[_docIndex], "OnQueryPageSettings", e); base.OnQueryPageSettings(e); }
protected override void OnPrintPage(PrintPageEventArgs e) { CallMethod(_documents[_docIndex], "OnPrintPage", e); base.OnPrintPage(e); if (e.Cancel) return; if (!e.HasMorePages) { CallMethod(_documents[_docIndex], "OnEndPrint", _args); if (_args.Cancel) return; _docIndex++; if (_docIndex < _documents.Length) { e.HasMorePages = true; CallMethod(_documents[_docIndex], "OnBeginPrint", _args); } } }
private void CallMethod(PrintDocument document, string methodName, object args) { typeof(PrintDocument).InvokeMember(methodName, BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, document, new object[] { args }); } } |
Nun möchte ich diesen gerne so erweitern, das man im Nachhinein noch ein weiteres Dokument dem MultiPrintDocument hinzufügen kann.
Habt ihr eine Idee wie ich das bewerkstelligen kann? Irgendwie muss man dem PrintDocument[] ein "normales" PrintDocument anhängen, aber wie bewerkstelligt man das man?
Vielen Dank.