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 | private void prn_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString("Hello from C#", new Font("Arial", 60, FontStyle.Regular), Brushes.Blue, 100, 100); } private void PrintTest() { Neevia.docCreator DC = new Neevia.docCreator(); DC.setParameter("DocumentOutputFormat", "PDF"); DC.setParameter("DocumentOutputName", "testCSHARP"); DC.setParameter("DocumentOutputFolder", @"c:\users\public\"); System.Drawing.Printing.PrintDocument prn = new System.Drawing.Printing.PrintDocument(); prn.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(prn_PrintPage); prn.PrinterSettings.PrinterName = "Neevia docCreator"; String tempFile = DC.getParameter("TempDir") + DC.GUID() + ".ps"; prn.PrinterSettings.PrintFileName = tempFile; prn.PrinterSettings.PrintToFile = true; prn.Print(); DC.setInputDocument(tempFile, ""); int RVal = DC.create(); DC.fileDelete(tempFile); prn = null; DC = null; if (RVal != 0) { MessageBox.Show("Error while creating document!!!"); } else { MessageBox.Show("Done !!!"); } } |