I'm attempting to build an ASP.NET (VB) application that will do
server-side printing of PDF files. I have used a Process object to
launch Adobe's AcroRd32 program with the /t switch which causes it to
open an Acrobat Reader window and silently send the document I want
printed to a local network printer:
Dim psiInfo As ProcessStartInf o = New ProcessStartInf o
(pathtoadobe, "/t " + filename + " " + printername)
psiInfo.CreateN oWindow = True
psiInfo.UseShel lExecute = True
Dim procPrint As Process = New Process()
procPrint.Start Info = psiInfo
procPrint.Start ()
This works nicely except for the fact that after it finishes printing,
the Acrobat window stays open on the server. I had thought the /t
switch would cause it to close when it was finished, but I was
apparently wrong. This is unacceptable, because after ten print runs
on the server, I'll end up with ten open acrobat windows!
How can I deal with this problem? It's a simple matter to kill the
process, but how do I know when it's done sending the job to the
printer? If I kill it too early, I could lose pages or corrupt the job
or worse. Is there any way to send something like a WM_COMMAND to the
Adobe window (if I can manage to get a handle to it)? Is there any way
for my to look at the printer's print queue within my ASP.NET code (if
I can do that, I can just check to see if the queue is empty, at which
point I'd know I can kill the process)? 1 4201
Just in case someone else has a similar issue someday, I thought I'd
post the solution I ended up finding.
It's easier to monitor the print queue. Basically you import two Win32
API calls (see pinvoke.net's winspool section for help on that). The
two you need are OpenPrinter and EnumJobs. Once that's done, it's a
simple matter to check the printer to see how many jobs are running on
it, and kill the Adobe process at the appropriate time. br*****@gmail.c om wrote: I'm attempting to build an ASP.NET (VB) application that will do server-side printing of PDF files. I have used a Process object to launch Adobe's AcroRd32 program with the /t switch which causes it to open an Acrobat Reader window and silently send the document I want printed to a local network printer:
Dim psiInfo As ProcessStartInf o = New ProcessStartInf o (pathtoadobe, "/t " + filename + " " + printername)
psiInfo.CreateN oWindow = True psiInfo.UseShel lExecute = True
Dim procPrint As Process = New Process() procPrint.Start Info = psiInfo procPrint.Start ()
This works nicely except for the fact that after it finishes printing, the Acrobat window stays open on the server. I had thought the /t switch would cause it to close when it was finished, but I was apparently wrong. This is unacceptable, because after ten print runs on the server, I'll end up with ten open acrobat windows!
How can I deal with this problem? It's a simple matter to kill the process, but how do I know when it's done sending the job to the printer? If I kill it too early, I could lose pages or corrupt the job or worse. Is there any way to send something like a WM_COMMAND to the Adobe window (if I can manage to get a handle to it)? Is there any way for my to look at the printer's print queue within my ASP.NET code (if I can do that, I can just check to see if the queue is empty, at which point I'd know I can kill the process)? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: vooose |
last post by:
Suppose execution of a particular thread T1 hits
Monitor.Enter(obj);
//critical section
and blocks at the first line. (ie someone else is in the critical
section) Now suppose more threads T2, T3... try to enter the critical
section and are blocked.
What is the order that the threads get to enter the critical section?
|
by: Charles Law |
last post by:
I've been using monitors a bit lately (some of you may have heard ;-) ) and
then up pop Manual and AutoResetEvents , and they look for all the world
like the same thing.
Are they interchangeable, or when should I use one over the other?
TIA
Charles
|
by: stephen |
last post by:
I have created an order form that users javascript to create a new html
document when the customers clicks the "print page" button.
Once the new document has been created it then prints the document and
closes it with the following code:
<body onload="window.print(); window.close();">
This works correctly (or at least the way I expect it to work under MS
Internet Explorer, but it cuases Netscape to "crash"
|
by: www.brook |
last post by:
I have a VC++.net code. Two threads are created, one thread keeps
appending elements to the queue, another keeps deleting an element from
the queue.
I tried to use monitor, but it seems that the there is problem. in the
thread of the deleting, seems that the deleting function entered twice
and both
try to delete the queue. The first thread find it is not empty, and try
to delete an element, but before this thread actually delete it,...
|
by: Jonathan Amsterdam |
last post by:
I think there's a slight design flaw in the Queue class that makes it
hard to avoid nested monitor deadlock. The problem is that the mutex
used by the Queue is not easy to change. You can then easily get
yourself into the following situation (nested monitor deadlock):
Say we have a class that contains a Queue and some other things. The
class's internals are protected by a mutex M. Initially the Queue is
empty. The only access to the...
| |
by: Russell Thomas |
last post by:
I wanted to see if anyone knew of anything in the .net framework 2.0 that I
could tap into for monitoring a printer’s print queue. I found some articles
about tying into the API but I was hoping for something cleaner that existed
in the framework. Basically I want to watch the print queue and when it gets
to a certain size or number of jobs I want to pause my app until it clears
out or lessens.
Thanks.
|
by: Perecli Manole |
last post by:
I am having some strange thread synchronization problems that require me to
better understand the intricacies of Monitor.Wait/Pulse.
I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock block
protecting a resource. Thread 2 and 3 also have a SyncLock block protecting
the same resource and after executing some code in their blocks they both do
a Monitor.Pulse to hand of the locked resource back to thread 1.
While thread 1 has...
|
by: Thomas Strauss, SRS |
last post by:
Hi,
I have a really hard time to find the access rights required for
monitoring a printing queue or share in windows XP or Win2000/2003 server.
We have an application that will remote control another app to print
files. To make it more reliable, the printjobs produced are monitored by
the application.
So the situation is: Application A controls application B. Application B
|
by: DeveloperX |
last post by:
Hi, Below is a hacked up version of an example I found on MSDN. My only
change was to add a third thread and some Sleeps. That's where my
question(s) comes in.
In the original it seems to work because Thread1 waits on Thread2 and
vice versa, although I can't quite see how.
Disabling Thread3 and leaving the sleep in works fine, processing is
nicely throttled. Activating Thread3 and we enter a world of pain. I
don't understand what the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |