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

HOWTO? Inject PCL code in print stream...

Status
Not open for further replies.

vroscigno

Programmer
Nov 12, 2002
8
US
Greetings,

I have an app that needs to inject PCL code snippets inline into my application's print stream. I've tried the Windows PASSTHROUGH Escape, but all my PCL snippets come out at the start of the print job. I need a solution that will work on all Windows platforms. Any ideas?

Thanks,
Vince
 
Thanks for the reply Jim. I discovered why PASSTHROUGH does not work as expected. The PCL driver appears to buffer output and invoke WritePrinter when it's output buffer is full (or crossing a page boundary). PASSTHROUGH simply calls WritePrinter directly and bypasses any buffered output. When the output buffer is finally flushed, it now follows the PASSTHROUGH data in the printer data stream.
I've come up with a different solution that seems promising. My app needs to turn printed output into a PCL Macro, so I print to a file. I must post-process this file to insert the macro definition commands, and to remove reset and UEL commands. I use GDI to 'print' my PCL escapes to force them into the print stream relative to other elements being printed. I use an escape 'placeholder' (currently 0x7f) because the PCL driver won't allow an application to print an 0x1b escape identifier. Then, during post-processing, I identify my escape placeholders and change them to the 'real' 0x1b escape identifier. There are two issues with this technique that must be addressed. First, the post-processor must ignore dynamic binary escape data (such as raster data) so it does not falsely interpret the escape placeholder. Second, the driver will clip (remove) any text that would fall off the page if printed. When 'printing' the PCL escape placeholder and data, I make sure this 'text' will not fall off the page by adjusting my horizontal print coordinate and embedding an equivalent relative cursor adjustment escape with the other escape data I want to insert. So far so good...

Regards,
Vince
 
Thanks for the Info. I've already written the code I need in order to do a proof of concept, and it seems to work quite well in practice. What I found of value from the referred link is a list of PCL escapes that are not allowed in a macro. That information has been very hard to find!
Thanks again,
Vince.
 
An alternate method of "injecting" PCL into a Windows print stream, is to do it as a "post-process". With PCLTool SDK, you can capture the print spool file, redirect it to PCLXForm and have a script "inject" whatever you need into the print stream. You can then re-direct the completed print stream to the printer's port and/or convert it into TIFF or PDF formats.

PageTech's PCLTool SDK Option V provides PCLXForm.exe for merging, decollating and streamediting PCL print streams. PCLXForm uses the most powerful PCL script programming language on the market. PageTech also provides free pre-sales analysis of PCL print streams provided. Just zip-up a sampling of the files that need to be transformed and provide your complete application, workflow, merging, indexing and other requirements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top