print a file pdf on server without to visualize it

  • Thread starter Thread starter Enrico Castagnola
  • Start date Start date
E

Enrico Castagnola

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

Thanks

Best regard
 
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
 
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
 
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
 
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
 
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
 
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
 
Back
Top