Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Print PDF/PS File Directly from VFP to printer
Message
De
07/01/2013 12:39:24
 
 
À
07/01/2013 12:22:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01561574
Message ID:
01561602
Vues:
59
It's been a long time since I did this last, sorry about that. Check if you can assign the printer to LPT1 or LPT2, then you can use
copy file (fullpath(yourfile.ps)) to LPT1
This means that you can NOT select the printer. If you really need that option, I am sorry that I can't help you.

>Ok Sir, I will Make two codes for PS and PDF But The following code suggested for PS is still not working
>
>lcOldPrinter = set('printer')
>cPrinter = getprinter()
>if !empty(lcPrinter)
> set printer to name( lcPrinter)Endif
>
>copy file (fullpath(yourfile.ps)) to printer
>set printer to name (lcOldPrinter)
>
>Line Number 5 i.e copy file (fullpath(yourfile.ps)) to printer is not printing on printer, rather it is creating a file named Printer
>and Line Number 6 is still giving the Spool Error as told you earlier
>
>My printer is HP 1160 Dont know whether it supports PS or not but I am Able to open the PS File using Double click and able to print the file using File--->Print Option. In this way file is printed but since there are millions of file , i am looking for code.
>
>
>
>
>
>
>Regards
>
>>You have to treat PS and PDF completely differently. In other words, you must create two separate programs, one for PS and one for PDF.
>>
>>PS can be copied to the printer, as I showed you in the first email, as long as your printer supports PS directly. If this is not the case, I can't help you. It's more than twenty years since I worked with PS files last, I hoped never to see them again...! :-)
>>
>>For PDFs you must use the code I provided which includes ShellExecute. But observe that that code will print to the default Windows printer, If you want to print to another printer, you must use the code in the link I provided to change the default Windows printer back and forth. You use Getprinter() to select the printer.
>>
>>If you can't get any of these programs to work, please show the complete code of the offending program.
>>
>>
>>>Thanks Sir,
>>>
>>>But there are still some problems
>>>
>>>First, it is working with PDF file but not Post Script (PS) file.
>>>
>>>Second, its giving the same error message(Error Accessing the Printer Spooler) now at the last line although I am able to print PDF.
>>>
>>> Third, Each & Every file is opened before print, since I have over 1 Lakhs file. it will be a problem if each file is opened before print. I need to direct all PS files directly to printer.
>>>
>>>
>>>Sample PS file is available at
>>>https://www.dropbox.com/s/239v7iljwa3kmlc/1010461602.ps
>>>
>>>I am Using code as
>>>
>>>lcOldPrinter = set('printer')
>>>lcPrinter = getprinter()
>>>
>>>if !empty(lcPrinter)
>>> set printer to NAME (lcPrinter)
>>>Endif
>>>
>>>DECLARE INTEGER ShellExecute IN "Shell32.dll" ;
>>> INTEGER hwnd, ;
>>> STRING lpVerb, ;
>>> STRING lpFile, ;
>>> STRING lpParameters, ;
>>> STRING lpDirectory, ;
>>> LONG nShowCmd
>>>
>>>ShellExecute(0, "print", FULLPATH("E:\Bills\lap\1010461602.ps"), "", "", 0)
>>>set printer TO Name(lcOldPrinter) && THIS IS ERROR GIVING LINE
>>>
>>>
>>>Regards
>>>Harsh
>>>
>>>
>>>
>>>
>>>>Sorry, I accidentally closed a tag in my browser, and had to rewrite the whole message. In doing that, I forgot the parenthesis.
set printer to NAME (lcPrinter)
>>>>I also forgot the code to print the PDF. I'm sorry for the confusion, I hope you are able to work this out. This is the code to print the PDFs.
>>>>DECLARE INTEGER ShellExecute IN "Shell32.dll" ;
>>>>   INTEGER hwnd, ;
>>>>   STRING lpVerb, ;
>>>>   STRING lpFile, ;
>>>>   STRING lpParameters, ;
>>>>   STRING lpDirectory, ;
>>>>   LONG nShowCmd
>>>>
>>>>ShellExecute(0, "print", FULLPATH(lcFileName), "", "", 0)
>>>>This code will print to the default Windows printer. So before and after this code you need to add the code to change the default Windows printer.
>>>>
>>>>>I have Emailed for making changes to Michel (mfournier@levelextreme.com)
>>>>>
>>>>>I Tried the code given by you, but its giving error at line
>>>>>
>>>>>set printer to NAME lcPrinter
>>>>>
>>>>>The error is "error accsessing Printer Spooler"
>>>>>How to overcome it.
>>>>>
>>>>>Harsh
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>You may have to send an email to Michel (mfournier@levelextreme.com) so that he changes your name, I am not quite sure about that. But please promise to do so, it feels so impersonal to talk to a "box".
>>>>>>
>>>>>>To print a PS, I am pretty sure that you can do it this way:
>>>>>>lcOldPrinter = set('printer')
>>>>>>lcPrinter = getprinter()
>>>>>>if !empty(lcPrinter)
>>>>>>   set printer to name lcPrinter
>>>>>>Endif
>>>>>>copy file (fullpath(yourfile.ps)) to printer
>>>>>>set printer to name (lcOldPrinter)
>>>>>>This code will printer to the default Windows printer. See here how you change this printer: http://www.berezniker.com/content/pages/visual-foxpro/changing-windows-default-printer. In your case you may have to save the current printer (Set('printer',1)) first, so that you can restore it afterwards.
>>>>>>
>>>>>>>I was looking for the user profile to change the name but didn't find it from where to change.
>>>>>>>
>>>>>>>Harsh
>>>>>>>
>>>>>>>
>>>>>>>>It's nice to "talk" to a person, and not a "box". Please change your name in your user profile, and we are ready to roll. As you have been told earlier, Universal Thread doesn't allow fake accounts.
>>>>>>>>
>>>>>>>>NB! Please excuse me for being so harsh with you. Pun intended. :-)
>>>>>>>>
>>>>>>>>>Good Repartee. "If you want to live in anonymously in a box".. Code Box. Well I dont to be in that at all.
>>>>>>>>>My name is Harsh.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>I want to help you, but by principle I don't help people who use a pseudonym. If you want to live in anonymously in a box, you should be prepared to take the consequences.
>>>>>>>>>>
>>>>>>>>>>Please change your name to your real name in the user profile.
>>>>>>>>>>
>>>>>>>>>>>I have a. DBF File that Contains Thousands of records having full path of the PDF/PS files.
>>>>>>>>>>>
>>>>>>>>>>>I.e
>>>>>>>>>>>
>>>>>>>>>>>FileName FULLPATH
>>>>>>>>>>>1234.PS C:\April\1234.PS
>>>>>>>>>>>567.PS C:\April\567.PS
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>I want to direct all the above files to print without opening these files
>>>>>>>>>>>
>>>>>>>>>>>Also If possible, before printing it should give a list of available printers so that user can select one.
>>>>>>>>>>>
>>>>>>>>>>>What is the command line printing command in VFP to this. Please Guide
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>Regards
>>
>>set printer to NAME lcPrinter
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform