garuka

garuka

  • NA
  • 26
  • 0

print and fax problem

Mar 2 2010 9:24 AM

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.

  1. private void printDocument(string fileName)  
  2.        {  
  3.            string userDir = getUserName(getReportId(fileName));  
  4.            string path = @outputDir + @"\" + userDir + @"\" + fileName;  
  5.            Thread.Sleep(1000);  
  6.            try  
  7.            {  
  8.                OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();  
  9.                myOleDbCommand.CommandText = "select reports_api.get_print_info('" + getReportId(fileName) + "') print_info from dual";  
  10.                OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();  
  11.                myOleDbDataReader.Read();  
  12.                string layout = myOleDbDataReader["print_info"].ToString();  
  13.   
  14.                if (layout != "NO_PRINT")  
  15.                {  
  16.                    System.Diagnostics.Process P = new Process();  
  17.                    P.StartInfo.FileName = path;  
  18.                    P.StartInfo.Verb = "Print";  
  19.                    P.StartInfo.CreateNoWindow = true;  
  20.                    P.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;  
  21.                    PrinterSettings setting = new PrinterSettings();  
  22.   
  23.                    if (layout == "LANDSCAPE")  
  24.                    {  
  25.                        setting.DefaultPageSettings.Landscape = true;  
  26.                    }  
  27.                    else  
  28.                    {  
  29.                        setting.DefaultPageSettings.Landscape = false;  
  30.                    }  
  31.   
  32.                    P.Start();                      
  33.                    P.Close();  
  34.                      
  35.                    P.Dispose();  
  36.                    writeLog("   " + " Printed " + path, Brushes.Green);  
  37.   
  38.                }  
  39.            }  
  40.            catch (Exception ex)  
  41.            {  
  42.                writeLog("   " + " Print error " + path, Brushes.Red);  
  43.                writeLog("   " + " Exception stack " + ex.StackTrace, Brushes.Red);  
  44.            }  


This is how I send the fax:


  1. FaxServer faxServer = new FaxServerClass();  
  2. faxServer.Connect(Environment.MachineName);  
  3. FaxDoc faxDoc = (FaxDoc)faxServer.CreateDocument(fullpath);  
  4. faxDoc.FileName = fullpath;  
  5. faxDoc.SendCoverpage = 1;  
  6. faxDoc.CoverpageName = @"C:\CoverFAX.cov";  
  7. faxDoc.CoverpageSubject = "Test Fax";  
  8. string bodyText = "This is a test";  
  9. bodyText += "list of products" + Environment.NewLine;  
  10. bodyText += "that should be on several lines";  
  11. faxDoc.CoverpageNote = bodyText;  
  12. faxDoc.FaxNumber = getFax(path);  
  13. faxDoc.DisplayName = "TestFax";  
  14. faxDoc.SenderName = faxSender;  
  15.  faxServer.Disconnect();  


Can someone guide me on how to print this into my default printer.