tags:

views:

910

answers:

2

What tools/methods are available to build pcl stream from PDFs.

We have a bunch of generated PDF files that get tied up into one big pdf. I need to generate a print job to print this with the ability to insert pcl escape sequences (to control paper feed and output bin stacking) per page. As of now we use the VB.Net printing classes, convert the PDF into a rasterized image using a third party tool to print. This does not allow us to insert PCL sequences into the print job.

So, basically, we need to process a bunch of PDFs, append them to the pcl and insert PCL commands as we go along. Is there a way to achieve this. Our application is written in VB.Net.

Any suggestions are greatly appreciated.

A: 

PCL and PDF are completly different languages, you cannot insert one into the other. If I had all the details I might recommend something different; however, based on what you have described I'd suggest converting the PDF documents to PCL using Ghostscript (using the ljet4 or other PCL output 'device' it includes) and then you can append/prepend any PCL commands data you need to control trays etc. Keep in mind that you probably won't be able to simply insert tray selections at the top, you'll need to move to an appropiate spot in the PCL stream and do this such as, after the E.

The one major downfall with this is that the PCL that Ghostscript creates is basically one large graphic per page so it's not effecient at all and doesn't provide you the ability to search in the PCL for text etc.

Things you haven't provided detail that might help recommend something more speicific include:

  • What is the ultimate goal, to have a PDF print on XYZ device, going to a specific tray and output?
  • Do you need to 'burst' this into multiple documents?
  • Does trays selection change throughout the document?
  • Is the document of mixed size or all the same size paper?
  • What other 'languages' does the device support? Such as PS/PCL/PCL-XL/PDF/TIFF/HTML/JPG...
  • Do you want to use PCL because you have to or because you are comfortable with it?

Other options you could use include:

  • Converting the PDF to PCL or Postscript and inserting PJL commands appropiate for that printer at the start of the job.
  • Inserting PJL at the start of the PDF document (this assumes that the printer can print PDF natively) and sending it strait to the device


EDIT: Adding further detail based on a discussion with innocentDev

Sorry for the late updated response, looks like you've sorted it out on your end.

If the end result is to take a PDF file and convert to something print printer understands while inserting tray selection commands at know spots then I think there are 2 solutions. You could do this as a conversion to PCL or Postscript. Postscript may be easier for the fact that PCL uses a FF (formfeed) control code to break each page and the FF character might appear throughout the page during a font declaration and/or graphic image.

If you do manage the break the document on the FF by splitting pages out of the individually or doing some extra work to determine that the FF is actually a page break and not one of the other instances of the character, or even finding some other element that you can break on (Ghostscript may have some other code at the start of each page that is consistent, I'm not 100% sure). Another way is to break the document into pages using Ghostscript or even pdftk, convert each page to PCL, insert the commands and concatenate the pages together; however, based on my previous comments regarding convert from PDF to PCL you might end up with a very large output file. This shouldn't impact print performance of the device but may slow data transmission etc.

If you go the PCL route, once you have it converted you simply need to add the appropriate PCL command for tray selection to each page in the document at the start of each page.

<esc>&lxH where x is the tray number.

There are some standards for this; however, devices with more than 3 trays often don't follow these standards and they've change a little over time as HP renumber things when they decided to remap the multipurpose tray from a multipurpose feeder to tray 1. Check your devices documentation or install their PCL print driver and print to file to the tray you want it to output to and you can see what number they use.

If you go Postscript you can do the same but breaking the pages may be easier as you can split the doucment (or at least look for) commands such as this:

%%Page: x x
%%BeginPageSetup

These always appear in Postscript output from Ghostscript. Once you find them you can insert a Postscript MediaSource command during the page setup and accomplish the same thing. You could even use the Postscript commands for media type or media colour. There are some generic commands for this but you might need to use something specific for the device you are outputting to. You can always review the device documentation, their PPD file or, what I often do, is print to file something from their driver and look at how they implement the coding.

Douglas Anderson
Douglas, Thanks a ton for your response.Answers to your questions above.1) see clarification in question.2) they are originally multiple docs. But we want all of it in one job.3) Yes. Tray selection keeps changing thoughout.4) Mixed sizes.5) Not sure. It is a Xeror 4112. However, we would like the solution to be flexible. It should work even if we replace with different printers.6) I am not comfortable with PCL at all. I am open to any other approach that will solve the problem.
DevByDefault
I am able to create the pcl out of the PDF files using ghostscript. I greatly appreciate the time Douglas has taken to help me with this. I would never have figured this out without your help.I can now edit the pcl and add some pcl escape sequences to it. The way to edit the PCL through code is to figure out some sequence that is constant within the generated pcl and append the new sequence to it. Though this is not a robust way of doing it, looks like this will work for my purpose.
DevByDefault
A: 

PCLTool SDK - Option V using PCLXForm.exe with a custom .TPT script is the only product that can streamedit the complex PCL generated from a Windows printer driver.

The demo is at www.pagetech.com. However, due to the need for expert level knowledge of PCL and the SDK stream edit functions. PageTech will probably have to write the custom script to your requirements. The ASCII text script would be editable by you should the PCL print stream change.

BP

Bob Pooley