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 10:06:18
 
 
À
07/01/2013 06:06:57
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:
01561593
Vues:
81
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
Harsh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform