473,396 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

2 Gig Print Spooler process

I'm printing a directory of about 500 multi-page tifs to a high speed
printer and the spooler process is killing me!!!

here is a little code.....

Public Function PrintImage(ByVal SourceFile As String) As Boolean

Try
ImageToPrint = FromFile(SourceFile)

PageNumber = 0
ImagePages = ImageToPrint.GetFrameCount(FrameDimension.Page())
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try

Try

PDocument.DocumentName = SourceFile
PDocument.Print()

Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
Return False
End Try

Return True

End Function

Then the event on the global variable PDocument is being raised for the
pages....

Private Sub PagePrintFunction(ByVal sender As Object, ByVal e As
PrintPageEventArgs) Handles PDocument.PrintPage
Try
ImageToPrint.SelectActiveFrame(FrameDimension.Page , PageNumber)

PageNumber = PageNumber + 1

e.Graphics.DrawImage(ImageToPrint, 0, 0,
(e.PageSettings.PaperSize.Width - 40), (e.PageSettings.PaperSize.Height -
50))

If PageNumber < ImagePages Then
e.HasMorePages = True
End If
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try
End Sub

This is not only really slow with larger images but as stated in the title,
my print spooler process turns into a 2 Gig memory monster after only about
160 images!!!!!!!!! Does anyone have a better solution or can tweak the
code? I'm kinda at my wits end over this. I've tried creating and
disposing of the PDocument variable in my loop that prints each file and
still the process grows.

MANY Thanks
Scott

Jul 24 '06 #1
9 2712
Scott M wrote:
I'm printing a directory of about 500 multi-page tifs to a high speed
printer and the spooler process is killing me!!!

here is a little code.....

Public Function PrintImage(ByVal SourceFile As String) As Boolean

Try
ImageToPrint = FromFile(SourceFile)

PageNumber = 0
ImagePages = ImageToPrint.GetFrameCount(FrameDimension.Page())
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try

Try

PDocument.DocumentName = SourceFile
PDocument.Print()

Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
Return False
End Try

Return True

End Function

Then the event on the global variable PDocument is being raised for the
pages....

Private Sub PagePrintFunction(ByVal sender As Object, ByVal e As
PrintPageEventArgs) Handles PDocument.PrintPage
Try
ImageToPrint.SelectActiveFrame(FrameDimension.Page , PageNumber)

PageNumber = PageNumber + 1

e.Graphics.DrawImage(ImageToPrint, 0, 0,
(e.PageSettings.PaperSize.Width - 40), (e.PageSettings.PaperSize.Height
- 50))

If PageNumber < ImagePages Then
e.HasMorePages = True
End If
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try
End Sub

This is not only really slow with larger images but as stated in the
title, my print spooler process turns into a 2 Gig memory monster after
only about 160 images!!!!!!!!! Does anyone have a better solution or
can tweak the code? I'm kinda at my wits end over this. I've tried
creating and disposing of the PDocument variable in my loop that prints
each file and still the process grows.

MANY Thanks
Scott
Just a quick thought.... I believe your problem is because the spooler
isn't purged until the last page is printed. Have you tried dividing
the overall print task into smaller numbers of pages, and then calling
the print function several times? You'd have to handle the Start-Page
for each call in this case, but it might work.... Then again, you might
just end up with several smaller spooler tasks that add-up to be 2 gig,
but I would at least expect each spooler process to be deleted once all
the pages in each process had been printed.

Anyone else tried this?

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jul 25 '06 #2
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.

Jul 25 '06 #3
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.
Jul 25 '06 #4
Scott M wrote:
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.
Could you monitor the size of the spooler directory and wait for it to go
down a bit before adding more print jobs to it?

Andrew
Jul 25 '06 #5
It doesn't go down. even after the service that spools the images is
restarted.

"Andrew Morton" <ak*@in-press.co.uk.invalidwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Scott M wrote:
>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.

Could you monitor the size of the spooler directory and wait for it to go
down a bit before adding more print jobs to it?

Andrew
Jul 25 '06 #6
Hi Scott,

Based on my experience, any type of image viewer software will have print
function build-in. You may choose one supports tif file, and try to print
the tif files one by one. I am not sure if mspaint.exe supports tif image,
can you give it a try?

Looking at the issue's nature, it is hard for us to give it a reproduce on
my side. It would require intensive troubleshooting which would be done
quickly and effectively with direct assistance from a Microsoft Support
Professional through Microsoft Product Support Services. They may perform
some remote debugging to your machine to identify the root cause.

You can contact Microsoft Product Support directly to discuss additional
support options you may have available, by contacting us at 1-(800)936-5800
or by choosing one of the options listed at
http://www.microsoft.com/services/mi...v_support.mspx

Finally, if you want to troubleshoot the spooler process memory issue, it
is helpful to use UMDH.EXE from windbg to. The tool can be used to obtain
call stack information of various memory block allocation of a process.
Please refer to below for more information:
"Umdhtools.exe: How to Use Umdh.exe to Find Memory Leaks"
http://support.microsoft.com/kb/268343/

Thanks for your understanding.

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.

Jul 26 '06 #7
>Scott M wrote:
>>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.
"Andrew Morton" wrote
>Could you monitor the size of the spooler directory and wait for it
to go down a bit before adding more print jobs to it?
Scott M wrote:
It doesn't go down...
What, not even after the images have been printed? I'm suggesting that
rather than try to sent umpteen gigabytes all in one go, you give the
printer (and print spooler) a chance to catch up/breathe. And avoid filling
up the disk the spool folder resides on.
...even after the service that spools the images is
restarted.
The print spooler service should not delete the files in the spool folder
just because it's been restarted.

The spool folder location is in the registry at
HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Print\Printers\DefaultSpoolDirec tory
(and other locations; I can't remember which one to set to change it).

Andrew
Jul 26 '06 #8
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.

Jul 26 '06 #9
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.

Jul 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dmitry Akselrod | last post by:
Hello Everyone, I have an almost well working Print Queue Monitoring software written. The software works quite well with typical Windows printing situations. However, there's a problem when a...
1
by: nhmark64 | last post by:
Hi, How do wait for a print spooler to be empty? My application sucks up all the CPU cycles after i print some reports. I want to delay the CPU intensive stuff until after the print...
0
by: RDI | last post by:
I need to watch a certain print spooler and if a print job appears, extract the print data to a PRN file on the hard disk and delete it from the spooler. Can VB.Net do this? If so, can someone...
1
by: =?Utf-8?B?QXVzdGluIFN0ZXBoZW5z?= | last post by:
In my commercial financial application I run a deposit report. I use an option to copy the report to the Clipboard. I then run a .NET consol app to “grab” the Clipboard and format the data...
2
by: James Wong | last post by:
Hi everybody, I would like to know whether there is a method to know how many pending jobs to be printed in print spooler from VB .NET 2005. My problem is that if a large document is sent to...
1
by: =?Utf-8?B?c2hlaWxh?= | last post by:
i have a lexmark series 1200 printer that was working fine untill we installed a new ink cartridge since then we have not been able to use printer have tried all listed solutions from run services...
1
by: =?Utf-8?B?c2hlaWxh?= | last post by:
i have a lexmark 1240 printer changed ink cartridge printer has not worked since have tried going to run services print spooler hitting automatic then start shows spooler started when i go back...
1
by: =?Utf-8?B?ZGF2aWR0aGV3ZWI=?= | last post by:
I have a recurring issue with a Print Spooler on a Windows 2000 Server. A print job will get stuck and take a large amount of the CPU time. I stop the print spooler in Services, go into Windows...
0
by: =?Utf-8?B?Sm9obg==?= | last post by:
If I'm posting in the wrong group please let me know. We've been experiencing issues with the print spooler service on our print server running Windows Server 2003 SP2. Occasionally the service...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.