• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to convert a pdf file to a pcl file in Java

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to find out how to convert a pdf file to a pcl file using java based API. Currently I am using a Adobe API through JACOB (Java COM Bridge) for this pcl creation but want to get out of that and use any Java based API or opensource.

I came across the StreamPrintService which can do such print file conversion but able to convert only a GIF file to a PS.

When I try to lookup for StreamPrintServiceFactory with input DocFlavor as GIF and output as PCL its saying no factories exist. Is this factory related to the Printers configured on my machine? I have tried the same after configuring the printer which prints PCL files but still no luck.

Code that I used is:



Appreciate any help.
 
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check these links

convert
converter

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi @Praveen Rajendran

Please help me about convert pdf to pcl file.
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After 11 years, it's unlikely that Praveen is still around. What is the reason for wanting to create PCL? Especially when starting out with a PDF?
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm really not sure what benefit there is to having PCL these days is myself, although my printer speaks PCL.

To get from PDF/PostScript to PCL when I print a document, my Linux machine's print manager passes the document to Ghostscript, which is a program that converts PostScript to printer-specific command codes. In normal operation, those command codes are then passed on to the printer, but Ghostscript is an independent app in its own right and you could just as easily output to a file.

However, Ghostscript is not Java so the best you could do would be a Runtime.exec() of it.
 
kumar swain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi @Tim Moores

is there open source dependency available for convert pdf to pcl?
 
Tim Moores
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt it. PDF is not a format that is amenable to being converted to another format. And if such a beast existed, I certainly would not expect it to be available for free.
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:I doubt it. PDF is not a format that is amenable to being converted to another format. And if such a beast existed, I certainly would not expect it to be available for free.


I don't know what you are talking about.

PDF is a container for PostScript graphics commands. All that's necessary to convert is to have your own PostScript interpreter (a stack-based machine) and a suitable renderer. The ghostscript application provides the interpreter and it drives plug-in renderers, including a renderer for PCL.

The ghostscript system has a GPL license and is widely used on Unix and Unix-like systems such as Linux. as the long-standing format used by application on those platforms for spooled print documents is PostScript.

As I said earlier, the Calibre document manager has the ability to convert documents between many popular formats, including epub, Kindle, PDF, RTF and more. Calibre doesn't have a "convert to PCL", as that's not considered to be a "document format", but it does also use ghostscript.

The final kicker is simply this: my printer doesn't speak Postscript. It runs on PCL4 and PCL5. Yet I routinely take Postscript documents and PDFs and spool them to the printer and they render just fine.

So there is definitely an open-source means of converting PDF to PCL. Again, though, ghostscript is written in C, not in Java.

A product that can read PDF's in Java is iText. It's not fully open open-source, but the Community Edition is AGPL, and there's a copy in the standard Maven repository, last updated last February (2022). Using iText to parse the PDF, if all else fails one can write one's own PCL generator.

Actually, back in 1992, I wrote a PCL interpreter. I was working for a company that was developing their own laser printer with a built-in PC and we needed to be able to render both raw Windows graphic commands (Window Metafile style) and PCL4.
 
Tim Moores
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:I don't know what you are talking about.


Yes, it seems so. I thought it was obvious that a Java solution was desired; but maybe that wasn't so obvious after all.
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was going on the premise that a Java solution was preferable, but any solution was better than none.

I should have remembere iText earlier, though. People have asked enough questions about it over the years.
 
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic