0 Replies - 1215 Views - Last Post: 10 December 2010 - 08:35 AM Rate Topic: -----

#1 Guest_Tripti*


Reputation:

print pdf from byte array

Posted 10 December 2010 - 08:35 AM

I am using ArcoRd32.exe(Acrobat Reader) to print pdf files from c# code using the following code. It takes a pdf file path from the file server as one of the arguments to print the file. I have my pdf files stored in the database and I am reading them in a byte array. Does anyone know if we can pass the byte array to AcroRd32.exe, instead of a file path from the file server. Any help will be highly appreciated and it will add more efficiency to my printing app, as I do not have to save file on the server before printing.
string AcrobatReaderPath = "C:\\Program Files (x86)\\Adobe\\Acrobat 4.0\\Reader\\acrord32.exe";
PrintMyPDF(AcrobatReaderPath, @"/t ""C:\Temp\_111663_FG08-006106_1_73.pdf"" ""BROTHER MFC-8890DW Printer""");

  private static void PrintMyPDF(string executable, string arguments) 
         {
           ProcessStartInfo starter = new ProcessStartInfo(executable, arguments);
           starter.CreateNoWindow = true;
           starter.RedirectStandardOutput = true;
           starter.UseShellExecute = false;
           Process process = new Process();
           process.StartInfo = starter;
           process.Start();
           StringBuilder buffer = new StringBuilder();
           using (StreamReader reader = process.StandardOutput) 
           {
            string line = reader.ReadLine();
            while (line != null) 
            {
             buffer.Append(line);
             buffer.Append(Environment.NewLine);
             line = reader.ReadLine();
             Thread.Sleep(100);
            }
           }
           if (process.ExitCode != 0) 
           {
            throw new Exception(string.Format(@"""{0}"" exited with ExitCode {1}. Output: {2}", 
        executable, process.ExitCode, buffer.ToString()));  
           }
      }



Is This A Good Question/Topic? 0

Page 1 of 1