Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to print .PDF files in the background using C#

1,247 views
Skip to first unread message

S_K

unread,
Apr 22, 2008, 3:55:21 PM4/22/08
to
Hi,

I have a directory full of a number of .PDF files that I need to
print.
Is there any simple way to do this?
Using PdfReader purhaps?

Thanks in advance.
Steve

Mark Rae [MVP]

unread,
Apr 22, 2008, 4:24:45 PM4/22/08
to
"S_K" <steve_...@yahoo.com> wrote in message
news:df6303b1-cf31-4154...@u69g2000hse.googlegroups.com...

> I have a directory full of a number of .PDF files that I need to
> print.
> Is there any simple way to do this?
> Using PdfReader purhaps?

As this is an ASP.NET newsgroup, are you trying to print these documents via
a web application i.e. through a web browser...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

S_K

unread,
Apr 22, 2008, 4:52:26 PM4/22/08
to
On Apr 22, 2:24 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "S_K" <steve_kers...@yahoo.com> wrote in message

I'm sorry. It's an ASP.NET web application.

Thanks

Mark Rae [MVP]

unread,
Apr 22, 2008, 5:06:33 PM4/22/08
to
"S_K" <steve_...@yahoo.com> wrote in message
news:3482a319-6f63-4549...@e39g2000hsf.googlegroups.com...

>>> I have a directory full of a number of .PDF files that I need to
>>> print. Is there any simple way to do this?
>>> Using PdfReader purhaps?
>>>
>> As this is an ASP.NET newsgroup, are you trying to print these documents
>> via
>> a web application i.e. through a web browser...?
>

> I'm sorry. It's an ASP.NET web application.

You're not going to be able to persuade a web application to control a
printer automatically for security reasons - all modern web browsers are
designed specifically to prevent this...

Your best bet would be to make the PDF documents available as hyperlinks.
This would allow the user to display the documents individually and print
them as required...

S_K

unread,
Apr 23, 2008, 11:01:13 AM4/23/08
to
On Apr 22, 3:06 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "S_K" <steve_kers...@yahoo.com> wrote in message

I'm sorry, there are over 300 .PDF documents stored on a remote
server. Displaying them indivitually and printing them is completely
out of the question! Is there anyway to print them on the server (not
client-web browser) side?

Steve

Mark Rae [MVP]

unread,
Apr 23, 2008, 3:14:46 PM4/23/08
to
"S_K" <steve_...@yahoo.com> wrote in message
news:9b4bce03-e5aa-4568...@p25g2000pri.googlegroups.com...

> I'm sorry,

There's no need to apologise...

> there are over 300 .PDF documents stored on a remote server.

> Displaying them individually and printing them is completely


> out of the question! Is there anyway to print them on the server (not
> client-web browser) side?

Yes, but not natively as PDF support isn't built into the .NET Framework.
However, there are many 3rd-party add-ins which you can use:
http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_en-GBGB252GB252&q=%22C%23%22+PDF+print

Alternatively, if this is a one-off exercise and you have networked or even
direct access to the server in question, maybe bespoke software is not the
most cost-effective solution...? Have you considered maybe just getting a
temp in and printing the documents manually? 300 documents isn't that
many...

S_K

unread,
Apr 23, 2008, 4:27:57 PM4/23/08
to
On Apr 23, 1:14 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "S_K" <steve_kers...@yahoo.com> wrote in message

>
> news:9b4bce03-e5aa-4568...@p25g2000pri.googlegroups.com...
>
> > I'm sorry,
>
> There's no need to apologise...
>
> > there are over 300 .PDF documents stored on a remote server.
> > Displaying them individually and printing them is completely
> > out of the question! Is there anyway to print them on the server (not
> > client-web browser) side?
>
> Yes, but not natively as PDF support isn't built into the .NET Framework.
> However, there are many 3rd-party add-ins which you can use:http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&r...

>
> Alternatively, if this is a one-off exercise and you have networked or even
> direct access to the server in question, maybe bespoke software is not the
> most cost-effective solution...? Have you considered maybe just getting a
> temp in and printing the documents manually? 300 documents isn't that
> many...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

Thanks Mark for your solution. I'll imediately look into it.
I do have direct access to the server in question.

By the way, thats 300 documents per week! While it would help the
unemployement rate to hire a temp to print the 300 documents, I would
rather just give my user a PRINT button that prints everything in the
server directory.

Thanks again. As always you have been very helpful!

Steve

Mark Rae [MVP]

unread,
Apr 23, 2008, 5:39:49 PM4/23/08
to
"S_K" <steve_...@yahoo.com> wrote in message
news:b4fa6487-474b-42f4...@x41g2000hsb.googlegroups.com...

> By the way, thats 300 documents per week! While it would help the
> unemployement rate to hire a temp to print the 300 documents, I would
> rather just give my user a PRINT button that prints everything in the
> server directory.

OK. In that case, and since you have direct access to the server in
question, I would strongly suggest that ASP.NET is not the right platform
for this...

Instead, I would recommend a WinForms app so that the printing exercise does
not put unnecessary strain on the web application...

George Ter-Saakov

unread,
Apr 24, 2008, 9:16:54 AM4/24/08
to
It's going to be hard to print document from server to clients printer.
Although it's possible.
1st step: You need to register printer on a server. Google "print from
Windows service" to see how to do it.
2nd step: Adobe Arobat support "DDE automation" or simple command string. So
something like
AcroRd32.exe /t "C:\test.pdf" "\\servername\printername" "AdobePS Tektronix
Phaser 840" "123.45.678.910"
will work

Visit this link http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm

-----------------------------------------------------------------------------------

How about merging all 300 pdfs into 1 big PDF file? Then you can open up it
in browser and have user to click "Print" button only once.
Then you do not need to mess with the printers/adobe....
Look for ITextSharp - free C# library to work with PDF.

George.


"S_K" <steve_...@yahoo.com> wrote in message

news:9b4bce03-e5aa-4568...@p25g2000pri.googlegroups.com...

net....@gmail.com

unread,
May 1, 2008, 2:55:55 AM5/1/08
to
On Apr 24, 6:16 pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> It's going to be hard to print document from server to clients printer.
> Although it's possible.
> 1st step: You need to register printer on a server. Google "print from
> Windows service" to see how to do it.
> 2nd step: Adobe Arobat support "DDE automation" or simple command string. So
> something like
> AcroRd32.exe /t "C:\test.pdf" "\\servername\printername" "AdobePS Tektronix
> Phaser 840" "123.45.678.910"
> will work
>
> Visit this linkhttp://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
>
> ---------------------------------------------------------------------------­--------
>
> How about merging all 300 pdfs into 1 big PDF file? Then you can open up it
> in browser and have user to click "Print" button only once.
> Then you do not need to mess with the printers/adobe....
> Look for ITextSharp - free C# library to work with PDF.
>
> George.
>
> "S_K" <steve_kers...@yahoo.com> wrote in message
>
> news:9b4bce03-e5aa-4568...@p25g2000pri.googlegroups.com...
> On Apr 22, 3:06 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
>
>
>
>
>
> > "S_K" <steve_kers...@yahoo.com> wrote in message
>
> >news:3482a319-6f63-4549...@e39g2000hsf.googlegroups.com...
>
> > >>> I have a directory full of a number of .PDF files that I need to
> > >>> print. Is there any simple way to do this?
> > >>> Using PdfReader purhaps?
>
> > >> As this is an ASP.NET newsgroup, are you trying to print these
> > >> documents
> > >> via
> > >> a web application i.e. through a web browser...?
>
> > > I'm sorry. It's an ASP.NET web application.
>
> > You're not going to be able to persuade a web application to control a
> > printer automatically for security reasons - all modern web browsers are
> > designed specifically to prevent this...
>
> > Your best bet would be to make the PDF documents available as hyperlinks.
> > This would allow the user to display the documents individually and print
> > them as required...

Create a small thick client application (let's call it the print
manager) that gets installed on the dealers machine's. This can be a
simple executable that need not run as a service or even in the task
tray. Once all of the documents have been generated (as separate
documents on the server) and saved to the appropriate location on the
server (preferably in the database) a special document should be
downloaded to the client (called a manifest) that contains a list of
all the files (or file IDs) that need to be printed as well as their
print options. The manifest should have a unique extension that is
recognized and associated with the print manager such that when the
file is opened, the print manager automatically launches. The print
manager will download each document listed in the manifest and
automatically print it. Because the print manager runs as a thick
client, it can directly communicate with the printer, setting the
approprate page size, orientation and duplex settings. Alternatively,
the manifest file could contain only the list of documents and the
print options could be sent as meta-data along with the document.
Prefered method for communicating with the server

dpk.k...@gmail.com

unread,
May 19, 2008, 4:03:48 AM5/19/08
to

Hi

I have a number of pdf files in a directory. i want to print all and
want a .ps file.

please suggest me.

How can i do this in C#?

Hoping to hear from your side.

thanks in advance

Arun PS

unread,
Jun 7, 2011, 2:04:59 AM6/7/11
to
ProcessStartInfo startInfo = new ProcessStartInfo();

startInfo.FileName = fileName; // use default app to execute verb
if (printer.IndexOf(@"\\") == 0)
{
//assert: this is a network path
startInfo.Verb = "printto";
startInfo.Arguments = "\"" + printer + "\"";
}
else
{
//assert: can only go to local default printer
startInfo.Verb = "print"; //prints to default printer
}

//try to keep Window hidden - work in background
startInfo.UseShellExecute = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;

//set process to startInfo and execute start
process.StartInfo = startInfo;

process.Start();
process.WaitForExit();
process.CloseMainWindow();
process.Close();

> On Tuesday, April 22, 2008 4:24 PM Mark Rae [MVP] wrote:

> As this is an ASP.NET newsgroup, are you trying to print these documents via
> a web application i.e. through a web browser...?
>
>

> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net


>> On Tuesday, April 22, 2008 5:06 PM Mark Rae [MVP] wrote:

>> "S_K" <steve_...@yahoo.com> wrote in message
>> news:3482a319-6f63-4549...@e39g2000hsf.googlegroups.com...
>>
>>

>> You're not going to be able to persuade a web application to control a
>> printer automatically for security reasons - all modern web browsers are
>> designed specifically to prevent this...
>>
>> Your best bet would be to make the PDF documents available as hyperlinks.
>> This would allow the user to display the documents individually and print
>> them as required...
>>
>>

>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net


>>>> On Wednesday, April 23, 2008 5:57 AM S_K wrote:

>>>> ia
>>>>
>>>> I am sorry. it is an ASP.NET web application.
>>>>
>>>> Thanks


>>>>> On Wednesday, April 23, 2008 3:14 PM Mark Rae [MVP] wrote:

>>>>> "S_K" <steve_...@yahoo.com> wrote in message
>>>>> news:9b4bce03-e5aa-4568...@p25g2000pri.googlegroups.com...
>>>>>
>>>>>

>>>>> There's no need to apologise...
>>>>>
>>>>>

>>>>> Yes, but not natively as PDF support isn't built into the .NET Framework.
>>>>> However, there are many 3rd-party add-ins which you can use:

>>>>> http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_en-GBGB252GB252&q=%22C%23%22+PDF+print


>>>>>
>>>>> Alternatively, if this is a one-off exercise and you have networked or even
>>>>> direct access to the server in question, maybe bespoke software is not the
>>>>> most cost-effective solution...? Have you considered maybe just getting a
>>>>> temp in and printing the documents manually? 300 documents isn't that
>>>>> many...
>>>>>
>>>>>

>>>>> --
>>>>> Mark Rae
>>>>> ASP.NET MVP
>>>>> http://www.markrae.net


>>>>>> On Wednesday, April 23, 2008 5:39 PM Mark Rae [MVP] wrote:

>>>>>> "S_K" <steve_...@yahoo.com> wrote in message

>>>>>> news:b4fa6487-474b-42f4...@x41g2000hsb.googlegroups.com...


>>>>>>
>>>>>>
>>>>>> OK. In that case, and since you have direct access to the server in
>>>>>> question, I would strongly suggest that ASP.NET is not the right platform
>>>>>> for this...
>>>>>>
>>>>>> Instead, I would recommend a WinForms app so that the printing exercise does
>>>>>> not put unnecessary strain on the web application...
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Mark Rae
>>>>>> ASP.NET MVP
>>>>>> http://www.markrae.net


>>>>>>> On Thursday, April 24, 2008 9:16 AM George Ter-Saakov wrote:

>>>>>>> It's going to be hard to print document from server to clients printer.
>>>>>>> Although it's possible.
>>>>>>> 1st step: You need to register printer on a server. Google "print from
>>>>>>> Windows service" to see how to do it.
>>>>>>> 2nd step: Adobe Arobat support "DDE automation" or simple command string. So
>>>>>>> something like
>>>>>>> AcroRd32.exe /t "C:\test.pdf" "\\servername\printername" "AdobePS Tektronix
>>>>>>> Phaser 840" "123.45.678.910"
>>>>>>> will work
>>>>>>>
>>>>>>> Visit this link http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
>>>>>>>
>>>>>>> -----------------------------------------------------------------------------------
>>>>>>>
>>>>>>> How about merging all 300 pdfs into 1 big PDF file? Then you can open up it
>>>>>>> in browser and have user to click "Print" button only once.
>>>>>>> Then you do not need to mess with the printers/adobe....
>>>>>>> Look for ITextSharp - free C# library to work with PDF.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> George.
>>>>>>>
>>>>>>>

>>>>>>> "S_K" <steve_...@yahoo.com> wrote in message

>>>>>>> news:9b4bce03-e5aa-4568...@p25g2000pri.googlegroups.com...
>>>>>>> On Apr 22, 3:06 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
>>>>>>>

>>>>>>> I'm sorry, there are over 300 .PDF documents stored on a remote
>>>>>>> server. Displaying them indivitually and printing them is completely
>>>>>>> out of the question! Is there anyway to print them on the server (not
>>>>>>> client-web browser) side?
>>>>>>>
>>>>>>> Steve


>>>>>>>> On Friday, April 25, 2008 11:31 PM S_K wrote:

>>>>>>>> On Apr 22, 3:06=A0pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
>>>>>>>> s


>>>>>>>>
>>>>>>>> I'm sorry, there are over 300 .PDF documents stored on a remote
>>>>>>>> server. Displaying them indivitually and printing them is completely
>>>>>>>> out of the question! Is there anyway to print them on the server (not
>>>>>>>> client-web browser) side?
>>>>>>>>
>>>>>>>> Steve


>>>>>>>>> On Friday, April 25, 2008 11:31 PM S_K wrote:

>>>>>>>>> On Apr 23, 1:14=A0pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
>>>>>>>>> gle.co.uk/search?sourceid=3Dnavclient&hl=3Den-GB&ie=3DUTF-8&r...
>>>>>>>>> n


>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks Mark for your solution. I'll imediately look into it.

>>>>>>>>> I do have direct access to the server in question.


>>>>>>>>>
>>>>>>>>> By the way, thats 300 documents per week! While it would help the
>>>>>>>>> unemployement rate to hire a temp to print the 300 documents, I would
>>>>>>>>> rather just give my user a PRINT button that prints everything in the
>>>>>>>>> server directory.
>>>>>>>>>

>>>>>>>>> Thanks again. As always you have been very helpful!
>>>>>>>>>
>>>>>>>>> Steve


>>>>>>>>>> On Thursday, May 01, 2008 11:09 PM net.anu wrote:

>>>>>>>>>> On Apr 24, 6:16=A0pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
>>>>>>>>>> So
>>>>>>>>>> x
>>>>>>>>>> -=AD--------
>>>>>>>>>> t
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> .
>>>>>>>>>> t


>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Create a small thick client application (let's call it the print
>>>>>>>>>> manager) that gets installed on the dealers machine's. This can be a
>>>>>>>>>> simple executable that need not run as a service or even in the task
>>>>>>>>>> tray. Once all of the documents have been generated (as separate
>>>>>>>>>> documents on the server) and saved to the appropriate location on the
>>>>>>>>>> server (preferably in the database) a special document should be
>>>>>>>>>> downloaded to the client (called a manifest) that contains a list of
>>>>>>>>>> all the files (or file IDs) that need to be printed as well as their
>>>>>>>>>> print options. The manifest should have a unique extension that is
>>>>>>>>>> recognized and associated with the print manager such that when the
>>>>>>>>>> file is opened, the print manager automatically launches. The print
>>>>>>>>>> manager will download each document listed in the manifest and
>>>>>>>>>> automatically print it. Because the print manager runs as a thick
>>>>>>>>>> client, it can directly communicate with the printer, setting the
>>>>>>>>>> approprate page size, orientation and duplex settings. Alternatively,
>>>>>>>>>> the manifest file could contain only the list of documents and the
>>>>>>>>>> print options could be sent as meta-data along with the document.
>>>>>>>>>> Prefered method for communicating with the server

erik.s...@gmail.com

unread,
May 25, 2016, 7:22:45 AM5/25/16
to
The most promising solution so far.
0 new messages