Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void PrintFormPdfData(byte[] formPdfData)
- {
- string tempFile;
- tempFile = Path.GetTempFileName();
- using (FileStream fs = new FileStream(tempFile, FileMode.Create))
- {
- fs.Write(formPdfData, 0, formPdfData.Length);
- fs.Flush();
- }
- try
- {
- string gsArguments;
- string gsLocation;
- ProcessStartInfo gsProcessInfo;
- Process gsProcess;
- gsArguments = string.Format("-grey -noquery -printer "HP LaserJet 5M" "{0}"", tempFile);
- gsLocation = @"C:Program FilesGhostgumgsviewgsprint.exe";
- gsProcessInfo = new ProcessStartInfo();
- gsProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
- gsProcessInfo.FileName = gsLocation;
- gsProcessInfo.Arguments = gsArguments;
- gsProcess = Process.Start(gsProcessInfo);
- gsProcess.WaitForExit();
- }
- finally
- {
- File.Delete(tempFile);
- }
- }
- ''' <summary>
- ''' Start Adobe Process to print document
- ''' </summary>
- ''' <param name="p"></param>
- ''' <remarks></remarks>
- Private Function printDoc(ByVal p As PrintObj) As PrintObj
- Dim myProcess As New Process()
- Dim myProcessStartInfo As New ProcessStartInfo(adobePath)
- Dim errMsg As String = String.Empty
- Dim outFile As String = String.Empty
- myProcessStartInfo.UseShellExecute = False
- myProcessStartInfo.RedirectStandardOutput = True
- myProcessStartInfo.RedirectStandardError = True
- Try
- If canIprintFile(p.sourceFolder & p.sourceFileName) Then
- isAdobeRunning(p)'Make sure Adobe is not running; wait till it's done
- Try
- myProcessStartInfo.Arguments = " /t " & """" & p.sourceFolder & p.sourceFileName & """" & " " & """" & p.destination & """"
- myProcess.StartInfo = myProcessStartInfo
- myProcess.Start()
- myProcess.CloseMainWindow()
- isAdobeRunning(p)
- myProcess.Dispose()
- Catch ex As Exception
- End Try
- p.result = "OK"
- Else
- p.result = "The file that the Document Printer is tryng to print is missing."
- sendMailNotification("The file that the Document Printer is tryng to print" & vbCrLf & _
- "is missing. The file in question is: " & vbCrLf & _
- p.sourceFolder & p.sourceFileName, p)
- End If
- Catch ex As Exception
- p.result = ex.Message
- sendMailNotification(ex.Message, p)
- Finally
- myProcess.Dispose()
- End Try
- Return p
- End Function
Add Comment
Please, Sign In to add comment