Hi,
I have this program which fetch pdf file from a specific directory and fax it to some number and then print it on my default printer as well.
Problem is:
Faxing and Printing separetely work fine.
But when I have fax and print it's not wroking properly. It sends the fax fine, but then it loads the print as another fax document (atttached tiff image) instead of printing it to physical printer.
So can anyone help me wit this.
Here is my priting code segment. I tried changing the verb to printTo as well. Same result.
private void printDocument(string fileName) { string userDir = getUserName(getReportId(fileName)); string path = @outputDir + @"\" + userDir + @"\" + fileName; Thread.Sleep(1000); try { OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand(); myOleDbCommand.CommandText = "select reports_api.get_print_info('" + getReportId(fileName) + "') print_info from dual"; OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader(); myOleDbDataReader.Read(); string layout = myOleDbDataReader["print_info"].ToString(); if (layout != "NO_PRINT") { System.Diagnostics.Process P = new Process(); P.StartInfo.FileName = path; P.StartInfo.Verb = "Print"; P.StartInfo.CreateNoWindow = true; P.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; PrinterSettings setting = new PrinterSettings(); if (layout == "LANDSCAPE") { setting.DefaultPageSettings.Landscape = true; } else { setting.DefaultPageSettings.Landscape = false; } P.Start(); P.Close(); P.Dispose(); writeLog(" " + " Printed " + path, Brushes.Green); } } catch (Exception ex) { writeLog(" " + " Print error " + path, Brushes.Red); writeLog(" " + " Exception stack " + ex.StackTrace, Brushes.Red); }
This is how I send the fax:
FaxServer faxServer = new FaxServerClass(); faxServer.Connect(Environment.MachineName); FaxDoc faxDoc = (FaxDoc)faxServer.CreateDocument(fullpath); faxDoc.FileName = fullpath; faxDoc.SendCoverpage = 1; faxDoc.CoverpageName = @"C:\CoverFAX.cov"; faxDoc.CoverpageSubject = "Test Fax"; string bodyText = "This is a test"; bodyText += "list of products" + Environment.NewLine; bodyText += "that should be on several lines"; faxDoc.CoverpageNote = bodyText; faxDoc.FaxNumber = getFax(path); faxDoc.DisplayName = "TestFax"; faxDoc.SenderName = faxSender; faxServer.Disconnect();