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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print 1 page to a file 1

Status
Not open for further replies.

petermeachem

Programmer
Aug 26, 2000
2,270
GB
Warning, rank beginner!

I need to produce a ppml file to print to an Indigo press. The ppml file will contain a reference to the page background picture, then a lump of postscript for the 1st page, then another reference to the picture and so on. Each of the lumps of ps will be different as they will contain a different name and address.
Using the Adobe generic ps driver, I can produce a page a file at a time. Problem is that it pops up a dialog box asking for the filename.
Is there any way I can get it to write a file without the popup, or do I need a different driver and if so each one?


 
How are you using the driver? Typically, applications use the driver to generate PostScript. So it's the application that is asking for a filename, not the driver.

So your question is best addressed as an application question. For example, the application might support an API with a "silent printing" command or property.

That said, allow me to pitch some thoughts? PPML can't do anything that PostScript can't.

There are a lot of posts in this forum and on my website in regard to reusable content caching with PostScript.

Since you already have the page image, and are already generating PostScript, it would be a very simple matter to integrate your reused page background as a PostScript form. It would take me less than 5 minutes, if you need help!

Every level 2 and 3 device, including the indigo, support PostScript forms for reusable content caching.

Also, since PostScript is a language, you can learn it and output it directly, with no need for an application or driver to produce it for you. You'll end up with much tighter, higher performance code than you'll get with application-generated PostScript or PPML.

Cheers!



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
I bow to your greater knowledge. However, it is the driver. I'm using the Adobe Generic PS driver which is set to output to a file. This is the bit of software that is asking for a filename. I'm printing a set of txTextcontrols (it's an activex) which can contain all sorts of formatting. I really don't want to parse through that lot to create PS, it would take ages. I don't really mind how the background gets printed so long as I don't get a copy of it with every page. There is no way that I can see of telling this ps driver 'kindly put this graphic from this file on every page'. Printer.PrintImage "c:\abc.jpg" would be nice!

 
If you can print your entire document through the driver, to create one multipage PostScript file, then it really is a simple matter to add some code at the top of that PostScript file. The code would see to it that the background image is printed every page, without having to include the background more than once.

You first include the background image as an EPS. Wrap it with procedures that turn the EPS into a filtered file.

Then, create a form which uses the filtered file in its PaintProc.

Last, define a /BeginPage procedure that calls the form.

Then, everytime your PostScript performs a "showpage", showpage will call /BeginPage, which executes the form, which draws the EPS on the page. Simple!

Here's the code you can use:

Code:
%!PS

/ImageData
currentfile
<< /Filter
   /SubFileDecode
   /DecodeParms
   << /EODCount 0 /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
%%TGREER: put your EPS between this comment...
%%TGREER: and this comment!
*EOD*
def

/LogoForm
<< /FormType 1
   /BBox [0 0 612 792]
   /Matrix [ 1 0 0 1 0 0]
   /PaintProc
   { pop
       /ostate save def
         /showpage {} def
         /setpagedevice /pop load def
         0 0 translate % change to the position you need
         1 1 scale     % remove or alter to change size
         ImageData 0 setfileposition ImageData cvx exec
       ostate restore
   } bind 
>> def

<<
   /BeginPage
   { gsave
       LogoForm execform
     grestore
   } bind

>> setpagedevice

%EOF

You need to make sure that your background image is an EPS, and that it contains no thumbnails, preview images, etc, and is in ASCII format.



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
What application are you printing from? You mention ActiveX, so are you using Visual Basic? Delphi?



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Ah. It all becomes clearer. I take it you are using the Printer.Print method to send output to a Windows Printer which is 1) using the PostScript Driver and is 2) set to "Print to File"?

The driver itself isn't prompting for the filename. Trust me on this; drivers don't have any user interface. All of the dialog boxes and printer settings etc. are part of the OS. The OS uses a driver to translate GDI to whatever, in this case PostScript. But the driver doesn't have an active role in what the user sees or doesn't in the way of dialog boxes. VB hands your print request to the OS, which sees the FILE: port, prompts for a filename, and the driver hasn't even seen a single byte yet. It's all the OS.

That's good in a way, because it leads us to a solution: create your own printer port.

On an "NT" OS, which includes Windows NT, 2000, and XP, you can add a Registry Key:

Code:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports

Create a new "string value", with the name being the full path to your file, "c:\tgreer_is_cool.ps", for example. (Sorry, sorry). Reboot. Go to your printer control panel and change the port to this port.

Now when you print to that printer, the output will go directly to that file.

Then you can open that file in VB, edit out any "PJL" junk, add the PostScript Form code, and you are in business.






Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Sorry no, I've been terribly busy. I will reply to the email you sent me too.

Well it sort of worked. It actually creates a file in c:\winnt\system32 the name of which is the name of the port. So if my port is called printtofile, I get a file called printofile in system32. Haven't sleuthed out why yet.

 
That's what it should do: the name of the port is the name of the file. If you don't provide a path, then c:\winnt\system32 is the default.



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top