If I have a PDF file, can Java convert it to PostScript or PCL? I
know ghostscript can take PDF and make PS out of it, I've done it.
What I'm looking for is an in-house developed (by me maybe) solution,
one that I can support without having to search the internet or
newsgroups for answers to. Just a "yes" or "no" answer will do. I
don't want to spend hours searching the Java Docs or other places if
there's no way to do it.
Arne Vajhøj - 14 Mar 2007 03:24 GMT
> If I have a PDF file, can Java convert it to PostScript or PCL? I
> know ghostscript can take PDF and make PS out of it, I've done it.
[quoted text clipped - 3 lines]
> don't want to spend hours searching the Java Docs or other places if
> there's no way to do it.
Of course Java can do it - Java can read a file and write a file.
The real question is: can you do it without writing a couple
of hundred thousand lines of Java code = does a suitable
library exist you can use.
I am not aware of any. But that does not mean that it does
not exist.
Arne
Alan Krueger - 14 Mar 2007 04:18 GMT
> If I have a PDF file, can Java convert it to PostScript or PCL? I
> know ghostscript can take PDF and make PS out of it, I've done it.
[quoted text clipped - 3 lines]
> don't want to spend hours searching the Java Docs or other places if
> there's no way to do it.
Google is more than GMail. Try searching for "java pdf library" and
"java postscript library".
John T - 14 Mar 2007 16:31 GMT
>> If I have a PDF file, can Java convert it to PostScript or PCL? I
>> know ghostscript can take PDF and make PS out of it, I've done it.
[quoted text clipped - 6 lines]
> Google is more than GMail. Try searching for "java pdf library" and "java
> postscript library".
I am well aware of the abilities of google (GIYF) However, I was simply
trying to ascertain from the group if what I am trying to do is possible.
Now that I know it is, I can procede to google and search. I was just not
prepared to search through dozens of documents and web sites if the
concensus was that Java does not have the ability to do what I need. Notice
this: I am not asking for a solution, only if the product is capable of
doing what I need.
Chris Uppal - 14 Mar 2007 20:49 GMT
> > > If I have a PDF file, can Java convert it to PostScript or PCL? [...]
> [...] I was simply
> trying to ascertain from the group if what I am trying to do is possible.
> Now that I know it is, I can procede to google and search.
Be aware that the PDF spec (as of version 1.7) runs to about 1300 terse and
informative pages -- so there's a lot of stuff in there...
http://www.adobe.com/devnet/pdf/pdf_reference.html
I quote from the spec:
===================
An application printing a PDF document to a PostScript
device must follow these steps:
1.Insert procedure sets containing PostScript procedure definitions to
implement the PDF operators.
2.Extract the content for each page. Each content stream is essentially the
script portion of a traditional PostScript program using very specific
procedures, such as m for moveto and l for lineto.
3.Decode compressed text, graphics, and image data as necessary. The
compression filters used in PDF are compatible with those used in PostScript;
they may or may not be supported, depending on the LanguageLevel of the target
output device.
4.Insert any needed resources, such as fonts, into the PostScript file. These
can be either the original fonts or suitable substitute fonts based on the font
metrics in the PDF file. Fonts may need to be converted to a format that the
PostScript interpreter recognizes, such as Type 1 or Type 42.
5.Put the information in the correct order. The result is a traditional
PostScript program that fully represents the visual aspects of the document but
no longer contains PDF elements such as hypertext links, annotations, and
bookmarks.
===================
(A conversion which the spec describes else where as "straightforward" ;-)
That doesn't mention the fact that some PostScript operators seem ("seem"
meaning "that's how I read it, but I may easily be wrong") to have subtly
different definitions in PDF, which may complicate matters (although, at a
guess, you can get decent results by ignoring that fact).
My point is that doing it yourself is going to be a fairly big job. There
isn't much in the way of free PDF parsers in Java out there (the only one I
personally know of is part of PDFBox[*]). Other than that you can expect
either to have to switch to a non-Java solution (which I think you implied you
don't want to do) or to a commercial one. The commercial ones all seem to be
moderately pricey -- O(1e3) $-US. Note that the ability to parse PDF doesn't
necessarily mean that you get easy access to the structures needed to convert
PDF to PostScript.
-- chris
[*] Although a somewhat limited version of JPedal seems to be available under a
GPL licence.
sss.zhou@gmail.com - 14 Mar 2007 06:52 GMT
On 3月14日, 上午9时41分, "printdude1...@gmail.com" <printdude1...@gmail.com>
wrote:
> If I have a PDF file, can Java convert it to PostScript or PCL? I
> know ghostscript can take PDF and make PS out of it, I've done it.
[quoted text clipped - 3 lines]
> don't want to spend hours searching the Java Docs or other places if
> there's no way to do it.
Yes. It seemes certainly that Java can do this. An input file converts
to an output file. Why wasn't able to? But I am more caring more about
how.
ck - 14 Mar 2007 07:56 GMT
On Mar 14, 10:52 am, "sss.z...@gmail.com" <sss.z...@gmail.com> wrote:
> On 3月14日, 上午9时41分, "printdude1...@gmail.com" <printdude1...@gmail.com>
> wrote:
[quoted text clipped - 10 lines]
> to an output file. Why wasn't able to? But I am more caring more about
> how.
Probably you can use iText library.
http://www.lowagie.com/iText/
You can get a list of other libraries at http://schmidt.devlib.org/java/document-libraries.html
--
Ck
http://www.gfour.net
Chris Uppal - 14 Mar 2007 21:08 GMT
I wrote:
> There
> isn't much in the way of free PDF parsers in Java out there (the only one
> I personally know of is part of PDFBox[*]).
I had forgotten all about the parser in Multivalent
http://multivalent.sourceforge.net/
-- chris