469,924 Members | 1,361 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

print a file pdf on server without to visualize it

Hi,
I have a problem.
How can I print a file pdf on server without to visualize it?

Thanks

Best regard
Nov 20 '05 #1
7 9303
Hi Enrico,

You need to use Acrobat's COM interface. For this you'll need the full
version of Acrobat - not just the reader.

The procedure is something like the following:

Imports Acrobat

Private oAcrobat As Acrobat.CAcroApp 'That Adobe App that we all know
and love.
Private oAcrobatDoc As Acrobat.CAcroPDDoc 'The required Pdf.
Private oDocView As Acrobat.CAcroAVDoc 'The Acrobat View of the doc.

'Start up Acrobat.
oAcrobat = CreateObject ("AcroExch.App")

'Skip the next line if you don't want Acrobat visible.
oAcrobat.Show

'Create a blank document object.
oAcrobatDoc = CreateObject ("AcroExch.PDDoc")
If oAcrobatDoc Is Nothing Then Stop

'Read in a given document.
Dim tSuccess As Boolean = oAcrobatDoc.Open (sDocPath & "Document.pdf")
If tSuccess = False Then Stop

'Create a view onto the document.
oDocView = oAcrobatDoc.OpenAVDoc ("Document.pdf")
If oDocView Is Nothing Then Stop

'Print all the pages.
uiLastPage = oAcrobatDoc.GetNumPages() - 1 '(0-based)
oDocView.PrintPages (0, uiLastPage, ?, ?, ?)

oDocView.Close (False)
oAcrobatDoc.Close()
oAcrobat.Exit()

oDocView = Nothing
oAcrobatDoc = Nothing
oAcrobat = Nothing

Good luck,
Fergus
Nov 20 '05 #2
Thanks for the interest.
The function printpages does not work. (oDocView.PrintPages(1, uiLastPage,
1, True, True))
The rest works why I succeed in reperire the number of the pages of the pdf.
Thanks


"Fergus Cooney" <fi******@tesco.net> ha scritto nel messaggio
news:#y**************@TK2MSFTNGP12.phx.gbl...
Hi Enrico,

You need to use Acrobat's COM interface. For this you'll need the full
version of Acrobat - not just the reader.

The procedure is something like the following:

Imports Acrobat

Private oAcrobat As Acrobat.CAcroApp 'That Adobe App that we all know and love.
Private oAcrobatDoc As Acrobat.CAcroPDDoc 'The required Pdf.
Private oDocView As Acrobat.CAcroAVDoc 'The Acrobat View of the doc.
'Start up Acrobat.
oAcrobat = CreateObject ("AcroExch.App")

'Skip the next line if you don't want Acrobat visible.
oAcrobat.Show

'Create a blank document object.
oAcrobatDoc = CreateObject ("AcroExch.PDDoc")
If oAcrobatDoc Is Nothing Then Stop

'Read in a given document.
Dim tSuccess As Boolean = oAcrobatDoc.Open (sDocPath & "Document.pdf") If tSuccess = False Then Stop

'Create a view onto the document.
oDocView = oAcrobatDoc.OpenAVDoc ("Document.pdf")
If oDocView Is Nothing Then Stop

'Print all the pages.
uiLastPage = oAcrobatDoc.GetNumPages() - 1 '(0-based)
oDocView.PrintPages (0, uiLastPage, ?, ?, ?)

oDocView.Close (False)
oAcrobatDoc.Close()
oAcrobat.Exit()

oDocView = Nothing
oAcrobatDoc = Nothing
oAcrobat = Nothing

Good luck,
Fergus

Nov 20 '05 #3
Hi Enrico,

|| The rest works why I succeed in reperire the number of the pages of the
pdf

?? I don't understand this.

My only idea is that the Acrobat documentation says that FirstPage is 0.
uiLastPage would therefore be NumPages - 1. But if you're setting uiLastPage
as I suggested you should get everything except the first page.

PrintPages comes back with True for success and False if there's no
document or an exception occurs.

I forgot to mention PrintPagesSilent which is the same function but
without the Print dialogue. It sends to the default printer.

Regards,
Fergus
Nov 20 '05 #4
Hi Fergus,

the function "PrintPagesSilent" returns false.

The document there is because the function "GetNumPages()" returns the
number of pages of the pdf.

What I can still make?

I have forgotten that printer is not connected to the server but is in LAN.

Printer default of the server is that in LAN.

Sorry for my english. I'am Italian.

Best regards

Enrico

"Fergus Cooney" <fi******@tesco.net> ha scritto nel messaggio
news:ub**************@tk2msftngp13.phx.gbl...
Hi Enrico,

|| The rest works why I succeed in reperire the number of the pages of the pdf

?? I don't understand this.

My only idea is that the Acrobat documentation says that FirstPage is 0. uiLastPage would therefore be NumPages - 1. But if you're setting uiLastPage as I suggested you should get everything except the first page.

PrintPages comes back with True for success and False if there's no
document or an exception occurs.

I forgot to mention PrintPagesSilent which is the same function but
without the Print dialogue. It sends to the default printer.

Regards,
Fergus

Nov 20 '05 #5
Hi Enrico,

I'm not great when it comes to printers!!

The question is whether it's a problem with Acrobat or whether it's the
printing itself.

You could try setting up your printer to print to a file. Then see if you
can get this file to go to the LAN printer manually.

You could set up the Acrobat PdfWriter printer driver and see if you can
print to that. This should simply make a copy of your document.

You could borrow a printer from someone and hook it up to your machine and
see if that prints.

If any or all of these work, then Acrobat is fine.

But how to get a LAN printer working ?? I've no ideas, I'm afraid. :-(

Good luck,
Fergus
Nov 20 '05 #6
Hi Enrico,

I just spotted the following code in another newsgroup:

Process.Start("C:\Program Files\Adobe\Acrobat
5.0\Reader\AcroRd32.exe", "/p /h ""C:\Program Files\Adobe\Acrobat
5.0\Help\ENU\ACROBAT.PDF""")

Using the command line may be a better approach than using automation.

And maybe not :-)

Regards,
Fergus
Nov 20 '05 #7
Hi Fergus,
I have forgotten that I am using a WEB ASP.NET
Regards, Enrico
"Fergus Cooney" <fi******@tesco.net> ha scritto nel messaggio
news:OD**************@TK2MSFTNGP09.phx.gbl...
Hi Enrico,

I just spotted the following code in another newsgroup:

Process.Start("C:\Program Files\Adobe\Acrobat
5.0\Reader\AcroRd32.exe", "/p /h ""C:\Program Files\Adobe\Acrobat
5.0\Help\ENU\ACROBAT.PDF""")

Using the command line may be a better approach than using automation.

And maybe not :-)

Regards,
Fergus

Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kitkat | last post: by
2 posts views Thread by billiejoex | last post: by
6 posts views Thread by Catalin Porancea | last post: by
4 posts views Thread by ESPN Lover | last post: by
7 posts views Thread by Robert Adkison | last post: by
reply views Thread by =?Utf-8?B?Sm9obg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.