Hi All

I have a requirement to develop a VB application to download a pdf file from a server using an example URL
http://xxxxxxxxxxxxx/pdffiles/yyyyy.pdf.

I need to perform a silent download and print the same to the local printer. As this is going to be a scheduled task, I need to perform a silent download and print.

Please help me if any pointers to the above.

Thanks in advance
Praveen

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Use the Microsoft Internet Transfer control.... You Pass it the URL, and tell it what you want to do with it, and it will do it. You can then save the information to a file, of the same name, or with a temporary name, and then do your printing. HOW exactly to print the PDF file from a VB App is going to be the hard part. The only method I know of, is really (Really) Tacky.

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi Comatose

Thanks for the reply.

I was able to obtain some VB code for printing a PDF file to default printer using a local VB application.

My hard part is for downloading the PDF file from Server. If you can give me more details on getting this done with Internet Transfer Protocol, it would be really great.

Can you give me some pointers on how to do the same? If possible, some hyperlinks etc?

Thanks a lot for the response.
Praveen

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Well,

It would go a little something like this:

Dim strURL As String
Dim bData() As Byte      ' Data variable

Dim intFile As Integer   ' FreeFile variable
strURL = "http://yourserver.com/yourpdf.pdf"

intFile = FreeFile()      ' Set intFile to an unused
                        ' file.
' The result of the OpenURL method goes into the Byte 
' array, and the Byte array is then saved to disk.

bData() = Inet1.OpenURL(strURL, icByteArray)

Open "C:\Temp\yourpdf.pdf" For Binary Access Write As #intFile
	Put #intFile, , bData()
Close #intFile
Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi Comatose

I really appreciate all your help.

I was able to tweak around with your code and got the code working. I am now able to download a PDF silently using VB Code.

Thanks once again
Praveen

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

The Pleasure is Mine.

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi Comatose

I have raised one more thread on PHP. Can you please let me know if you have any idea on the same too?

Thanks
Praveen

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

I'm sorry,

I don't use PHP as a general rule, and therefore, I have no idea how to go about using sockets, and LWP and the like. If you needed it in perl, that would be no problem, however, There are others more proficient in PHP that can give you help.

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi,

Does anybody know how to automate printing of PDF files using VB or C++. I have to print 100 pdf files at a time and trying to find someting like .Print to do it.

Thank you in advance.

Alex

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80
Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

THANK YOU very much.......

:lol:

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

HI CAN YOU PLEASE TELL ME HOW YOU DO THE PRINTING

Thanks
Sabitha

Hi All

I have a requirement to develop a VB application to download a pdf file from a server using an example URL
http://xxxxxxxxxxxxx/pdffiles/yyyyy.pdf.

I need to perform a silent download and print the same to the local printer. As this is going to be a scheduled task, I need to perform a silent download and print.

Please help me if any pointers to the above.

Thanks in advance
Praveen

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

The solution to printing the PDF file was referenced in URL: http://www.vb-helper.com/howto_print_pdf.html

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi thank you for the quick response, but since I am using activex Control the code cannot be used by me .. do you have any other alternative.

Regards
Sabitha

The solution to printing the PDF file was referenced in URL: http://www.vb-helper.com/howto_print_pdf.html

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

what does the activex control do? Are you using a control to actually LOAD the .pdf file into the VB app? What I mean is... I don't understand why you can't use the activeX control, to do whatever it does, and also use the dde printing code?

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi,

The control is not used to load the pdf. One of the options in the control should print the pdf without displaying, the following line gives error in DDE code

txtAcrobatDDE.LinkMode = 2

This is not allowed in an activex control

Thanks

what does the activex control do? Are you using a control to actually LOAD the .pdf file into the VB app? What I mean is... I don't understand why you can't use the activeX control, to do whatever it does, and also use the dde printing code?

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Ok, This way isn't as elegant as I'd like for it to be, but it should work for you. Stick The following code into a module:

public sub print_pdf(xSomeFile as string)
	Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /p /h " & xSomeFile, vbHide
end sub

Keep in mind, that if adobe is a different version, or in a different path, then you will need to change the path (and possibly the .EXE name) to fit wherever you hvae installed adobe. If you are doing this for a bunch of different machines, something to consider is to search the registry for the path to the adobe exe, and use that instead of a hard coded path (which is the best way), and then call the adobe exe with the /p and /h options that way. You would use this subroutine in your code somewhere as follows:

call print_pdf "c:\mydocument.pdf"

let me know if that works for you.

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

WOW great!!!, I looked into similar code, then I did not have the ans on how to find the path for "AcroRd32.exe". Thank you .

Regards
Sabitha

Ok, This way isn't as elegant as I'd like for it to be, but it should work for you. Stick The following code into a module:

public sub print_pdf(xSomeFile as string)
	Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe /p /h " & xSomeFile, vbHide
end sub

Keep in mind, that if adobe is a different version, or in a different path, then you will need to change the path (and possibly the .EXE name) to fit wherever you hvae installed adobe. If you are doing this for a bunch of different machines, something to consider is to search the registry for the path to the adobe exe, and use that instead of a hard coded path (which is the best way), and then call the adobe exe with the /p and /h options that way. You would use this subroutine in your code somewhere as follows:

call print_pdf "c:\mydocument.pdf"

let me know if that works for you.

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

It's My Pleasure.

You are able to get the path now then?

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

It's My Pleasure.

You are able to get the path now then?

Hi, Comatose

I have a similar problem that is to try to find a path to the AcroRD32.exe from the registry. I realise that version for adobe can be different from one computer to another. Recently, I've almost completed a database using Microsoft Access 2003 for someone'else and written a manual as to how to use it in pdf file format.

I know where it is stored i.e. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\AcroRd32.exe.

This is how the code is written as follows

shell "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppPaths\AcroRd32.exe c:\testing.pdf", vbnormalfocus

It didnot work. Could you please tell me what went wrong or missing?

Thank you in advance.

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi,

can you please expalain a little bit more about this:

"bData() = Inet1.OpenURL(strURL, icByteArray)"

coz im having error on this line... sorry but I'am just not very much familiar in VB... Thanks

Well,

Dim strURL As String
Dim bData() As Byte      ' Data variable
 
Dim intFile As Integer   ' FreeFile variable
strURL = "http://yourserver.com/yourpdf.pdf"
 
intFile = FreeFile()      ' Set intFile to an unused
                        ' file.
' The result of the OpenURL method goes into the Byte 
' array, and the Byte array is then saved to disk.
 
bData() = Inet1.OpenURL(strURL, icByteArray)
 
Open "C:\Temp\yourpdf.pdf" For Binary Access Write As #intFile
    Put #intFile, , bData()
Close #intFile
Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

I'm having a runtime error '424'

object required...

do i need to add something like reference....

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Hi Comatose

I really appreciate all your help.

I was able to tweak around with your code and got the code working. I am now able to download a PDF silently using VB Code.

Thanks once again
Praveen

Hi Praveen,
Can you please share your VB code. I need to down multiple files which are stored datewise on our local server? My email id is rbnaik@gmail.com

Re: Using VB Code - Silent download pdf from server and print to local printer 80 80

Thank you Comotose - you pointed me in the right direction with regard to printing PDFs from within VB6. Cheers. Mike. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.