I'm not too sure what you mean. I've changed the code considerably since
I've last posted it (trying to figure out what is happening). Installed new
print drivers and messed with settings on the printer with our own hardware
support (Direct printing instead of spooling the print jobs)
It's just a huge enigma to me. Even after the application hasn't been
printing for over two hours now the spoolersv.exe process stands at
1,140,324 K in task manager. the users printed about 700 single page tiff
files today. Here is the code that printed the images.
Private Sub PagePrintFunction(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
Static Dim PageNumber As Integer = 0
Try
ImageToPrint.SelectActiveFrame(FrameDimension.Page , PageNumber)
PageNumber += 1
e.Graphics.DrawImage(ImageToPrint, New RectangleF(0, 0,
(e.PageSettings.PaperSize.Width - 40), (e.PageSettings.PaperSize.Height -
50)))
If PageNumber < ImagePages Then
e.HasMorePages = True
Else
e.HasMorePages = False
e.Graphics.Dispose()
PageNumber = 0
End If
Catch ex As Exception
General.WriteToEventLog("PagePrintFunction" & vbCrLf &
ex.ToString, "Print Class", EventLogEntryType.Error)
Throw ex
End Try
End Sub
Public Function PrintImage(ByVal SourceFile As String) As Boolean
Try
ImageToPrint = FromFile(SourceFile)
ImagePages = ImageToPrint.GetFrameCount(FrameDimension.Page())
Catch ex As Exception
General.WriteToEventLog("Getting Image Frames: " & vbCrLf &
ex.ToString, "Print Class", EventLogEntryType.Error)
End Try
Try
Using PDocument As New PrintDocument
PDocument.PrinterSettings.PrinterName = PrinterName
PDocument.DocumentName = SourceFile
AddHandler PDocument.PrintPage, AddressOf PagePrintFunction
PDocument.Print()
End Using
Catch ex As Exception
General.WriteToEventLog("Print Document: " & vbCrLf &
ex.ToString, "Print Class", EventLogEntryType.Error)
Return False
End Try
Return True
End Function
Public Sub PrintFolderContents()
Dim ExtensionFilter As String = "*." & Filter
Dim FileNameList As String() = Directory.GetFiles(Folder,
ExtensionFilter)
Try
General.WriteToEventLog("Starting to print " & Folder, "Print
Class", EventLogEntryType.Information)
FileNameList = Directory.GetFiles(Folder, ExtensionFilter)
Array.Sort(FileNameList)
If _ToggleArchiveBit Then
turnOffSwapFileBits(FileNameList)
End If
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try
Try
For i As Integer = 0 To FileNameList.Length - 1
If PrintImage(FileNameList(i)) Then
If _ToggleArchiveBit Then
turnOnAttributeBit(FileNameList(i))
End If
Else
General.WriteToEventLog("File " & FileNameList(i) & "
did not properly Print.", "Print Class", EventLogEntryType.Warning)
End If
Next
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
Finally
If Not ImageToPrint Is Nothing Then
ImageToPrint.Dispose()
End If
End Try
End Sub
The speed at which the jobs are pushed into the printer is less then optimal
as well.
"Michael D. Ober" <obermd.@.alum.mit.edu.nospamwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
This actually sounds like a bug in the Printimage function. Does this
function close each print job properly. By this I mean are the spool
files closed once they have been created. I have seen image processing
programs not properly close the images when they are done with them.
Mike Ober.
"Scott M" <sc*****@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>The Printimage function gets called 500 times for tiffs that have about
10 - 30 pages in each. I haven't installed the service on any other
machines to see if it will konk out the server there, either.
I really stinks to have to restart the spooler and to restart the machine
after only printing 100 tiffs.
And as far as other software, Jeff. What do you suggest? This is a
server side process for a production orientated environment so I can't
have much downtime.
Thanks
Scott
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:zP**************@TK2MSFTNGXA01.phx.gbl...
>>Hi Scott,
Thanks for your post!
Does your tif file have 500 frames or do you have 500 files in a
directory
for printing?
ShaneO's reply seems make sense, you may give it try and feedback the
result here.
Regarding this issue, I recommend you try to use some existing softwares
that can read these tif files for printing, can this problem be
reproduced?
I suspect it may be a bug of spooler process since your code snippet is
really simple.
Anyway, I will wait for your feedback. Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
================================================ ==
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================ ==
This posting is provided "AS IS" with no warranties, and confers no
rights.