Print the tiff file from a .Net Windows service

We created an application that receives several files in different formats, pdf, tiff, jpeg, doc, etc. Upon receipt, they are converted to tiff files using a third-party print driver, which is installed locally on the server and installed as the default printer. To do this, we open System.Diagnostics.Process with the command line and arguments for printing the file with the corresponding application.

Now the new version should be a Windows service, and so far everything is working fine, except for the printed part. Whenever a process starts, it never throws an exception, and everything seems to work fine, but the file never prints. If I open the task manager, I will see that MS Paint was executed (in the case of the jpeg file), but there is no tiff output file.

As a side note, the final file must be a tiff file due to another third-party tool that our client uses, and this is the only format that it supports.

Any help would be greatly appreciated. Sergio Romero

The code we use is as follows:

private const string PROCESS_COMMAND = "mspaint.exe";  
private const string PROCESS_ARGUMENTS = @"""{0}""";  

Process proc = new Process();  
ProcessStartInfo startInfo = new ProcessStartInfo();  
string error = string.Empty;  

startInfo.FileName = PROCESS_COMMAND;  
startInfo.Arguments = string.Format(PROCESS_ARGUMENTS, fileFullPath);  
startInfo.UseShellExecute = false;  
startInfo.RedirectStandardError = true;  

proc.EnableRaisingEvents = false;  
proc.StartInfo = startInfo;  

proc.Start();  

using(StreamReader errorReader = proc.StandardError)  
{  
    string standardError = string.Empty;  
    while((standardError = errorReader.ReadLine()) != null)  
    {  
        error += standardError + " ";  
    }  
}  
proc.WaitForExit();
+3
source share
5 answers

, , - . , , ..

-, MS Paint, . .NET System.Drawing.Image.FromFile(YourImageFilePath) PrintDocument, ...

PrintDocument, ( , ..), PrintPage , - e.Graphics.DrawImage(YourTiffImageObject, New Rectangle (0), 0, e.MarginBounds.Width, e.MarginBounds.Height)), TIFF . , PrintDocument.Print .

,.NET - - .

, ( SelectActiveFrom TIFF e.HasMorePages = True PrintPage, ), .

UPDATE: , , , ... . MS Paint, " " .

+3

MSPaint... , , , -, .

, , .

0

, , , / ,

0

MSPaint ? , , , ; . , MSPaint , UI .

.NET? . System.Printing, . , , tho. ...

0

, . / - " ", ( mspaint) .

, , MSPaint .NET, , , .NET. - , MSPaint , LibTIFF , Ghostscript, , .NET, PDF.

0

Source: https://habr.com/ru/post/1699124/


All Articles