Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command line print to file

Status
Not open for further replies.

tty0

Programmer
Nov 13, 2002
108
GB
Now then,
I need to take an rtf file and print to file as i need a pcl file generating. My thoughts were to just put the command through exec i.e.

exec("cmd PRINT c:\\test.txt /D: FILE");

However, this doesnt work for me. So i have tried using WSHscript as per below to see if i can get notepad to pop up just so i know i have something working, if it did i was going to plan on using vbs this way, but still to no avail, the bottom one is the last way i have tried.

$WshShell = new COM("WScript.Shell");
$WshShell->Run("notepad", 3, false);

any help greatly appreciated

cheers

'mi casa es su casa'
]-=tty0=-[
 
i don't use a windows computer any more. but some thoughts:

* why do you need the CMD part? and if you really do need to, i suggest that you use an absolute reference c:/windows/system32/cmd.exe
* does the php process have the right permissions to execute cmd.exe?
* where do you specify the output file name?
* does the command execute correctly if typed on the command line (as the php process user
 
You could also look into producing HPGL documents and send them to HP compatible printers as well.

Here is a class that should help you get started


When printing, I just send the file directly to the device thus eliminating the need to shell out (can you use this term in WIN?) and run CL scripts or executeables.



--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
I missed the fact that you intent to "print to a file" ...[ponder]

Why not just write to the target file using standard file IO functions?




--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Hi Southbeach,
Thanks for that class, it saves a lot of code should I need to go down that route. I could use that and write straight to file using file IO. However, the windows print to file option would automatically write a string containing the original file data into pcl format automatically. Which would solve all the problem as its sat on a windows server at the moment.

cheers
chris


'mi casa es su casa'
]-=tty0=-[
 
It sounds like a poor's man version of text to pcl ...

I do not see how this is of a benefit. What do you intend to do with the file later?

If your file is properly formatted, whether HPGL, PCL, TXT, RTF, HTML + CSS, if you later choose to print it it should print just fine.

I like HPGL because it will work on any PCL compatible printer.

Have you tried HTML + CSS or XML + XSL ???


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Unfortunately the system i have to send it to only accepts PCL files.

I start off with up to 200 different rtf templates, replace some text and save the rtf file. Then i have to convert the rtf file into a pcl file, (which in windows the print to file works great) but this all has to be done server side in a script, PHP running on IIS. Then the resulting PCL file is encoded in base 64 and encapsulated inside an XML packet and sent using Curl to an xml gateway for processing.

The system behind the gateway only accepts PCL files and the whole thing has to be autonomous so its not as if i can generate the rtf and then manually print to file as we are talking hundreds of transactions per hour.

cheers
chris

'mi casa es su casa'
]-=tty0=-[
 
i think we are back to my post of 24th June. can you respond please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top