8

I am looking to create (as a proof-of-concept) an OCaml (preferably) program that converts PCL code to PDF format. I am not sure where to start. Is there a standardized algorithm for doing so? Is there any other advice available for accomplishing this task?

Thanks!

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
Mat Kelly
  • 2,327
  • 7
  • 29
  • 51
  • sounds like an ugly task. Were you planning on using ocamllex and ocamlyacc? – nlucaroni Mar 20 '09 at 16:43
  • nlucaroni, as I'm sure you know, I've been trying to get my hands dirty with OCaml and I have a problem that I would like to solve with my slowly accumulating OCaml knowledge. I am unfamiliar with the two you mention. Is there an approach you ca recommend? – Mat Kelly Mar 20 '09 at 17:40
  • yes I have noticed. ocamllex and ocamlyacc are lexer and parsers for a grammar. I know nothing of PCL and cannot recommend using them, but it seems like it could be a possibility. – nlucaroni Mar 20 '09 at 20:26

3 Answers3

2

Ghostscript developers have recently integrated their sister products GhostXPS, GhostPCL and GhostSVG into their Ghostscript source code tree. (It's now called GhostPDL.) So all of these additional functionalities (load, render and convert XPS, PCL and SVG) are now available from there.

This means you could build their language switching binary from their sources. This, in theory, can consume PCL, PDF and PostScript and convert this to a host of other formats. While it worked for me whenever I needed it, Ghostscript developers recommend to stop using the language switching binary (since it's 'almost non-supported' -- see KenS' comment to this answer) and instead switch to using the explicit binaries pcl6.exe (PCL input), gsvg.exe (SVG input, also 'almost non-supported') and gxps.exe (support status unclear to me).

So to 'convert PCL code to PDF format' as the request areads, you could use the pcl6 command line utility, a sister product to Ghostscript's gs/gswin32c.exe.

Sample commandline:

 pcl6.exe  \
  -o output.pdf  \
  -sDEVICE=pdfwrite  \
   [...more parameters as required (optional)...]  \
  -f input.pcl

Updated as per KenS' hints in the comment....

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • 1
    Just a passing note, please don't use pspcl6.exe if you want to do PCL to PDF conversion, please use pcl6.exe. pspcl6.exe is a 'language switch' build which is almost non-supported and we don't recommend its use. – KenS May 29 '12 at 14:35
  • @KurtPfeifle: When I try to run the same on HP-UX, I am receiving below error. Any ideas? /ghostPDL/ghostpdl-9.16/main/obj/pcl6 -sOutputFile=out.pdf -sDEVICE=pdfwrite inputpclfile.PCL Bus error(coredump) – MoG May 07 '15 at 16:50
  • @MohanGajula: Sorry, no idea. Did you build the HP-UX `pcl6` binary yourself? Does the problem occur with each and every input PCL file, even the most simplest ones? – Kurt Pfeifle May 07 '15 at 17:13
  • @KurtPfeifle - Yeah. I built it myself using the ghostPDL 9.16 version. my PCL is really simple. Has below lines. ^[(s1p22v0s0b4197T ^[*p183x99Y TEST HEADER LINE ^[(s11V ^[*p183x155Y BODY LINE This happens only when I try to convert something from PCL to PDF using pcl6. If I don't specify any options and just execute pcl6, its giving me the regular help info like Usage, Options, Version, Build date, Devices. – MoG May 07 '15 at 17:22
  • @KenS Is pcl6.exe supported on XP SP3? I get `not regular win32 application' – Hrvoje T Jun 21 '17 at 11:03
  • The short answer is that open source users aren't eligible for support at all..... Also, XP is no longer supported (except for loads of money) by Microsoft, we don't support obselete operating systems. All of that said, I know of no reason why it shouldn't work. Note that the current Windows executable is called gpcl6win32.exe, or gpcl6win64.exe, not pcl6.exe. If you have a (recent) binary by that name, we didn't build it. – KenS Jun 21 '17 at 14:46
2

Conversion of PCL to PDF can be incredibly complex (assuming you need it to be generic and not just for simple PCL). We've investaged this many times and in the end always revert to using other tools. We keep investigating as we are a development shop who uses and understands all elements of PCL to great detail. If you are not really familure with PCL it will be daunting task. One of the major issues is that overtime, printers have become, for the most part, tollerent of malformed PCL and as such, creating something that follows the rules to the letter of the law is not always sufficient. If; however, you have control over the PCL, you may be able to work it out with some amount of success.

I don't mean to turn you off of this and I realize that you've come here looking for a programming answer but I have to say, this is a far from simple task and there are no 'standarized algorithms' for this (that I'm aware of).

If this is designed to be a tool to work alongside of somehting else you are building I'd highly recommend looking at these guys:

PageTech

This is by far the most complete set of tools (Windows) for handling this. There are a few others but, based on our extensive use of PCL and conversion tools over the years, this is the only one that work all the time.

EDIT: Most recently we've been working with LincPDF (http://www.lincolnco.com/). This is also an excellent product with has one big benefit, deployment is simple. Some of the other tools have complex software installations. This solution is very easy for us to deploy as a feature in an application. It's also faster then any tools we've tested to date (at least with the PCL that we generate from our apps which is quite complex as they include specialized fonts and macros).

Douglas Anderson
  • 4,652
  • 10
  • 40
  • 49
1

There is a series of reference books from HP; you could re-implement a PCL parser and output corresponding PDF.

You might start with the "PCL 5 Printer Language Technical Reference Manual" (http://h20000.www2.hp.com/bc/docs/support/SupportManual/bpl13210/bpl13210.pdf) . Search HP for more (http://search.hp.com/query.html?qt=PCL+reference).

Or you could steal code or ideas from GhostPCL (http://www.ghostscript.com/GhostPCL.html)

Joe Koberg
  • 25,416
  • 6
  • 48
  • 54