Linked by Thom Holwerda on Thu 10th Jun 2010 12:53 UTC
Linux This is a problem I've been dealing with for a while now. I have a Lexmark printer which I've bought without checking for compatibility with Linux (I bought it when I was still using Windows), and as it turns out, this printer is not supported in Linux. I switched to Linux on my main desktop full-time late last year, so instead of to my desktop, I hooked this printer up to my bedroom Windows 7 media server/HTPC, and whenever I need to print, I just drop the file in question on this machine, and print form there. I need a better solution. Update: As it turns out, Lexmark has recently started releasing Linux drivers (good stuff). Still, the problem at hand stands, as there might still be other printers that suffer from the same problem.
Thread beginning with comment 429513
To read all comments associated with this story, please click here.
brewmastre
Member since:
2006-08-01

Here Thom, I have a present for you. True, it's a dirty hack that I threw together just now but it does provide some basic functionality. Basically, create the directory C:\Queue and share it. then run the following VB.NET hack on your system. Whenever you print in Linux you can just print to file and save the .PDF output to the share \\yourserver\queue and the program will send it to the default printer. there are many limitations but I'm sure it could be cleaned up:

Imports System.Diagnostics
Imports System.IO

Module modBasicQueue

Sub Main()
'******************************Written by Matt Paulauskas*********************************
'****************************************2010************************ *********************

Const qd = "C:\Queue\"
Console.WriteLine("Waiting for file to print")

Do '//continuous file check/print/delete loop
If Directory.GetFiles(qd).Count > 0 Then '//Check for files...if found send to printer and delete
For Each qFile As String In Directory.GetFiles(qd) '// iterate through files
Try
Dim psi As New ProcessStartInfo
With psi
.Verb = "print"
.WindowStyle = ProcessWindowStyle.Hidden
.FileName = qFile
.UseShellExecute = True
.Arguments = "/silent"
End With

'// Display file being printed
Console.WriteLine("Printing: " & qFile)
Dim proc As New Process
proc.StartInfo = psi
proc.Start()
Threading.Thread.Sleep(500)
TryAgain:
'//clean up after file has been printed
Try
File.Delete(qFile)
Catch ex As Exception
'//file was probably locked by the app resonsible for printing it
'//Sleep the thread for 20ms and try again
Threading.Thread.Sleep(20)
GoTo TryAgain
End Try

'//Clean up running process
Try
proc.Kill()
Catch ex As Exception

End Try
Catch ex As Exception
Console.WriteLine("Print Operation: " & ex.Message)
End Try
Next
End If '//end file check
Threading.Thread.Sleep(1000) '//pause before next check
Loop
End Sub

End Module

Reply Score: 6

sorpigal Member since:
2005-11-02

This is an interesting approach but to make it seamless it would be better to set up a print-to-file printer that automatically saves to the share, thus avoiding the need to copy.

Reply Parent Score: 2