Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-04

Pascal postscript reading library

23 messages · 11 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I did some googling, and I think there is none, but just in case ... does anyone know a pascal library to read postscript files? Preferably open source. Liberal licensing (linking to proprietary code) is indispensable.

If not then there will be one in a couple of months =)

I need to interpret information from a .ps file and generate output based on that.

bye,

Felipe Monteiro de Carvalho
Florian Klaempfl
to Felipe Monteiro de Carvalho
Show quoted text 11 lines
Hello, I did some googling, and I think there is none, but just in case ... does anyone know a pascal library to read postscript files? Preferably open source. Liberal licensing (linking to proprietary code) is indispensable. If not then there will be one in a couple of months =) I need to interpret information from a .ps file and generate output based on that.

PS is really complex, it's a full programming language after all. I would consider a Ghostscript wrapper.

Felipe Monteiro de Carvalho
to Florian Klaempfl
Florian Klaempfl wrote
PS is really complex, it's a full programming language after all. I would consider a Ghostscript wrapper.

The problem is that you have to buy it for non-GPL projects, but thanks a lot for the tip, I will evaluate if their price make it worth it.

A very big problem of their selling system is that they don't have publicly available prices, and they are the sole holders of the copyright, so, if they sudenly decide to raise their prices for me, I'm completely locked to 1 vendor.

thanks,

Felipe Monteiro de Carvalho
Ricardo Aguiar
to Felipe Monteiro de Carvalho: I did some googling, and I think there is none, but just in case ... does anyone know a…

Greetings.

In Linux (at least in Debian) there is a program named "extract" who extracts text from .pdf and .ps files. This program uses a dynamic library (libextractor) and your program can use it dynamically without any problem.

The only restriction is about linking against static libraries. You can link commercial software against dynamic libs at will (as you will not be using the libs code, but only the libs calls).

Ric.

Felipe Monteiro de Carvalho wrote 13 lines
Hello, I did some googling, and I think there is none, but just in case ... does anyone know a pascal library to read postscript files? Preferably open source. Liberal licensing (linking to proprietary code) is indispensable. If not then there will be one in a couple of months =) I need to interpret information from a .ps file and generate output based on that. bye,
Felipe Monteiro de Carvalho
to Ricardo Aguiar

Hello,

Ricardo Aguiar wrote
In Linux (at least in Debian) there is a program named "extract" who extracts text from .pdf and .ps files. This program uses a dynamic library (libextractor) and your program can use it dynamically without any problem.

Thanks, but I actually need to extract a vectorial drawing from the .ps file, and not text. If there is any text, if should be completely transparent to me, i.e. I'd rather receive the curves that form a text then it's encoded representation.

Felipe Monteiro de Carvalho
Ricardo Aguiar
to Felipe Monteiro de Carvalho: Thanks, but I actually need to extract a vectorial drawing from the .ps file, and not…

Greeintgs again!

There is another program named "pstoedit". They have a site:

http://www.pstoedit.net/

Ok, it is in C/C++. But I hope this can help you. Reinvent the wheel is always dificult.

This all raises a question: What about the dificulty of using external C/C++ libs in Linux (and windows) using fpc? Just "external C" the functions in a .inc , link with the (dynamic) lib and we are done? I didn't test it yet.

Ric.

Felipe Monteiro de Carvalho wrote 8 lines
Hello, [.....] Thanks, but I actually need to extract a vectorial drawing from the .ps file, and not text. If there is any text, if should be completely transparent to me, i.e. I'd rather receive the curves that form a text then it's encoded representation.
Krishna
to Felipe Monteiro de Carvalho: I did some googling, and I think there is none, but just in case ... does anyone know a…
Felipe Monteiro de Carvalho wrote 7 lines
Hello, I did some googling, and I think there is none, but just in case ... does anyone know a pascal library to read postscript files? Preferably open source. Liberal licensing (linking to proprietary code) is indispensable.

How about converting the postscript to PDF and using PDF parsing libs from pascal?

If not then there will be one in a couple of months =)

Wow! (even though I feel it is a little too optimistic ;) )

I need to interpret information from a .ps file and generate output based on that.

Hmm... vague your mail is. What kinda interpretation? If all you want is to slurp the text then it might be possible but then Postscript is a full blown programming language and people (mostly) come up with their own operators for showing text...

As someone else has mentioned, Ghostscript is an option. I remember reading about the api for accessing the interpreter although long back.

Cheers,
-Krishna

One reason that life is complex is that it has a real part and an imaginary part -Andrew Koenig
Felipe Monteiro de Carvalho
to Krishna
Krishna wrote
Hmm... vague your mail is. What kinda interpretation? If all you want is to slurp the text then it might be possible but then Postscript is a full blown programming language and people (mostly) come up with their own operators for showing text...

Ok, I think it's time to explain a little bit more in detail what I am trying to do.

I am building a CNC Machine. It's like a 3D printer, it can cut into wood and metal and build objects, or generate drawings (not with ink, but through cutting) into existing objects.

The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable.

So at this point I need to convert postscript into Machine commands, i.e. move to start position, start drilling, move X, Y, move again, etc ... end.

I don't need to parse everything from postscript, just the absolute minimum to extract the vectorial drawing coordinates, start point and end point.

I am a little impressed that everyone says postscript is so complex, so I'm reevaluating which path to go, but I do have a competent software developer available to whom send the task, so the amount of work isn't that much a problem =P (as long as it is doable by 1 person in a couple of months)

Felipe Monteiro de Carvalho
Marc Santhoff
to Felipe Monteiro de Carvalho

Hi Felipe,

Felipe Monteiro de Carvalho wrote 7 lines
The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable.

Do you have a description of Corels file format? If so I'd be strongly interested in getting a link or copy, up to now I thought their format is proprietary and not documented.

The only source I know is the old SDK for version 8, today version 14 is out. And the old one is full of errors, as can be read in the source of ... I think it must be Skencil (formerly named Sketch).

TIA,
Marc

Krishna
to Felipe Monteiro de Carvalho: Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am…
Felipe Monteiro de Carvalho wrote 26 lines
On Wed, Apr 23, 2008 at 4:32 AM, Krishna wrote: > Hmm... vague your mail is. What kinda interpretation? If all you want > is to slurp the text then it might be possible but then Postscript is > a full blown programming language and people (mostly) come up with > their own operators for showing text... Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am building a CNC Machine. It's like a 3D printer, it can cut into wood and metal and build objects, or generate drawings (not with ink, but through cutting) into existing objects. The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable. So at this point I need to convert postscript into Machine commands, i.e. move to start position, start drilling, move X, Y, move again, etc ... end. I don't need to parse everything from postscript,

Postscript needs no parsing as you can directly interpret it with data and graphics stacks.

just the absolute minimum to extract the vectorial drawing coordinates, start point and end point.

I suggest you take a look at the library provided by ghostscript and also the various gs widgets.

Show quoted text 6 lines
I am a little impressed that everyone says postscript is so complex, so I'm reevaluating which path to go, but I do have a competent software developer available to whom send the task, so the amount of work isn't that much a problem =P (as long as it is doable by 1 person in a couple of months)

just curious: does corel draw generate vectorial output? otherwise your postscript output will contain a huge (ugly) bitmap...

cheers,
-Krishna

One reason that life is complex is that it has a real part and an imaginary part -Andrew Koenig
Felipe Monteiro de Carvalho
to Marc Santhoff: Do you have a description of Corels file format? If so I'd be strongly interested in…
Marc Santhoff wrote
Do you have a description of Corels file format? If so I'd be strongly interested in getting a link or copy, up to now I thought their format is proprietary and not documented.

Not really. Reading directly from Corel Draw files was just a very initial idea, immediately put aside when we found a way to generate postscript with the printer driver, and now it really seams unfeasable.

At the moment I am considering either trying to parse just the subset of PostScript that the virtual printer that we use generates or using some postscript to pdf converter and then parsing the PDF.

CorelDraw can export to PDF, you could try to read from that.

What kind of project are you developing?

Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho
to Krishna: On Wed, Apr 23, 2008 at 3:59 PM, Felipe Monteiro de Carvalho Postscript needs no parsing…
Krishna wrote
I suggest you take a look at the library provided by ghostscript and also the various gs widgets.

The free Ghostscript is dual license. GPL2 or some no-comercial use license.

I can't use GPL2 because my software is proprietary. I cannot use the no-comercial license because my project is comercial.

Proprietary licenses for Ghostscript can only be bought if you buy a very large volume.

so Ghostscript is absolutely out of question.

just curious: does corel draw generate vectorial output? otherwise your postscript output will contain a huge (ugly) bitmap...

http://en.wikipedia.org/wiki/CorelDRAW

Felipe Monteiro de Carvalho
Marc Santhoff
to Felipe Monteiro de Carvalho: Not really. Reading directly from Corel Draw files was just a very initial idea,…

Am Mittwoch, den 23.04.2008, 08:36 -0300 schrieb Felipe Monteiro de Carvalho:

Show quoted text 17 lines
On Wed, Apr 23, 2008 at 8:19 AM, Marc Santhoff wrote: > Do you have a description of Corels file format? If so I'd be strongly > interested in getting a link or copy, up to now I thought their format > is proprietary and not documented. Not really. Reading directly from Corel Draw files was just a very initial idea, immediately put aside when we found a way to generate postscript with the printer driver, and now it really seams unfeasable. At the moment I am considering either trying to parse just the subset of PostScript that the virtual printer that we use generates or using some postscript to pdf converter and then parsing the PDF. CorelDraw can export to PDF, you could try to read from that. What kind of project are you developing?

Nothing using Corels file format currently, but quite a while ago I have started a small file indexer that grabs metadata out of some file types. If it could look into CD files (Version 9 mostly) independant of the platform it is running on, that would be nice.

Another question is if Corel has made the step from proprietary file formats to using XML inbetween, I would think about updating and file conversion then.

Marc

Funky Beast
to Felipe Monteiro de Carvalho: Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am…
Felipe Monteiro de Carvalho wrote 35 lines
On Wed, Apr 23, 2008 at 4:32 AM, Krishna wrote: > Hmm... vague your mail is. What kinda interpretation? If all you want > is to slurp the text then it might be possible but then Postscript is > a full blown programming language and people (mostly) come up with > their own operators for showing text... Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am building a CNC Machine. It's like a 3D printer, it can cut into wood and metal and build objects, or generate drawings (not with ink, but through cutting) into existing objects. The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable. So at this point I need to convert postscript into Machine commands, i.e. move to start position, start drilling, move X, Y, move again, etc ... end. I don't need to parse everything from postscript, just the absolute minimum to extract the vectorial drawing coordinates, start point and end point. I am a little impressed that everyone says postscript is so complex, so I'm reevaluating which path to go, but I do have a competent software developer available to whom send the task, so the amount of work isn't that much a problem =P (as long as it is doable by 1 person in a couple of months)

Hi,

Looks like a CNC Machine Center. Why not export it to DXF? It has all the ingrediants (endpoints, center of arc, arc radius, etc...) you need to generate CNC machine codes. You can extend from the dxf component at: http://www.efg2.com/Lab/Library/Delphi/Graphics/FileFormatsAndConversion.htm

PS: Wow ... you build CNC machines! Custom build or standard ones? Any links to your product site?

HTH,
Funky Beast

Felipe Monteiro de Carvalho
to Funky Beast
Funky Beast wrote
Looks like a CNC Machine Center. Why not export it to DXF? It has all the ingrediants (endpoints, center of arc, arc radius, etc...) you need to generate CNC machine codes. You can extend from the dxf component at: http://www.efg2.com/Lab/Library/Delphi/Graphics/FileFormatsAndConversion.htm

Looks a nice format. I still need to see if CorelDraw can export to it, but nothing stops us from supporting multiple import formats.

PS: Wow ... you build CNC machines! Custom build or standard ones? Any links to your product site?

I would say standard ones. Our website is here, but it's only available in portuguese:

http://www.avisobr.com/

Our current project isn't yet available there, as we are still developing it. I'll see what I can do about adding an english translation to the website.

thanks,

Felipe Monteiro de Carvalho
Funky Beast
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Looks a nice format. I still need to see if CorelDraw can export to it, but nothing stops us from supporting multiple import formats.

Most if not all CAD or vectorial software out there supports import/export from/to DXF format. If you support importing this format, you would already support a plethora of designing software out there. Your customers will have more choices for their favourite designing tool.

I'll see what I can do about adding an english translation to the website.

Thanks.

Regards,
Funky Beast

Luiz Americo Pereira Camara
to Felipe Monteiro de Carvalho: Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am…
Felipe Monteiro de Carvalho wrote 10 lines
On Wed, Apr 23, 2008 at 4:32 AM, Krishna wrote: The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable.

Did you consider exporting to svg?. Sometime ago a pascal svg reader appeared in one of the fpc/Lazarus lists

Luiz

Marc Weustink
to Felipe Monteiro de Carvalho: Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am…
Felipe Monteiro de Carvalho wrote 34 lines
On Wed, Apr 23, 2008 at 4:32 AM, Krishna wrote: > Hmm... vague your mail is. What kinda interpretation? If all you want > is to slurp the text then it might be possible but then Postscript is > a full blown programming language and people (mostly) come up with > their own operators for showing text... Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am building a CNC Machine. It's like a 3D printer, it can cut into wood and metal and build objects, or generate drawings (not with ink, but through cutting) into existing objects. The drawing will most likely come from CorelDraw. We are developing a printer driver which will then use a ready made virtual printer which is able to generate postscript as output, which will make our driver very simple to build. I could read the CorelDraw files directly, but I'd rather not be stuck to 1 drawing software, and CorelDraw may change their files in the future, but postscript is likely to remain stable. So at this point I need to convert postscript into Machine commands, i.e. move to start position, start drilling, move X, Y, move again, etc ... end. I don't need to parse everything from postscript, just the absolute minimum to extract the vectorial drawing coordinates, start point and end point. I am a little impressed that everyone says postscript is so complex, so I'm reevaluating which path to go, but I do have a competent software developer available to whom send the task, so the amount of work isn't that much a problem =P (as long as it is doable by 1 person in a couple of months)

Interpreting postcript is doable, but postscript contains way more info than you need.
If it is just moveto and lineto you need, you may want to consider using a HPGL plotter driver. HPGL is a textual "language" used for plotters. It consists mostly of commands like: get pen, move to, line to (and a few others I forgot)

Marc

Graeme Geldenhuys
to Funky Beast: Most if not all CAD or vectorial software out there supports import/export from/to DXF…
Funky Beast wrote
Most if not all CAD or vectorial software out there supports import/export from/to DXF format. If you support importing this format, you would already support a plethora of designing software out there. Your customers will have more choices for their favourite designing tool.

I agree with that. DXF is the de-facto standard file format that 99% of the CAD and Engineering software support. I have a friend that runs his own engineering firm. I asked him about this and he said, over the years they switched designing software and all of them supported DXF files.

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Johann Glaser
to Felipe Monteiro de Carvalho: Ok, I think it's time to explain a little bit more in detail what I am trying to do. I am…

Hi!

Show quoted text 5 lines
I am a little impressed that everyone says postscript is so complex, so I'm reevaluating which path to go, but I do have a competent software developer available to whom send the task, so the amount of work isn't that much a problem =P (as long as it is doable by 1 person in a couple of months)

Please note that PostScript is actually a full features programming language, which (just "accidentially") has some commands suitable to draw on a page. So, in PostScript there are infinite different ways to describe an identical page. Compare to a "descriptive" printer language or drawing/image format (like HPGL, PDF, DXF, SVG, PCL, JPG, ...) where only the order but not the way an element is expressed can be different.

AFAIK in PostScript you can express a lot of difficult stuff like clipping paths (even a font can be a clipping path for your drawing). So, while a PS interpreter is relatively easy to develop (for a computer scientist), the printing engine (controlled by the PostScript program) is not recommend to search either for
- a descriptive printer language / page description language
- a postscript interpreter which offers the page in some descriptive terms (e.g. a list of elements)

Bye
Hansi

PS: Since you are developing a Windows printer driver you could simply convert the GDI commands to the CNC commands without the PostScript intermediate step. But I dislike this option because this would give a fully platform-dependent driver.

Tiziano De Togni
to Graeme Geldenhuys: I agree with that. DXF is the de-facto standard file format that 99% of the CAD and…

Graeme Geldenhuys ha scritto:

Show quoted text 10 lines
Funky Beast wrote: > Most if not all CAD or vectorial software out there supports > import/export from/to DXF format. If you support importing this format, > you would already support a plethora of designing software out there. > Your customers will have more choices for their favourite designing tool. I agree with that. DXF is the de-facto standard file format that 99% of the CAD and Engineering software support. I have a friend that runs his own engineering firm. I asked him about this and he said, over the years they switched designing software and all of them supported DXF files.

This is true if you deal with metal sheet and mechanical applications.

But when you deal with cutting/engraving applicazions, PostScript is preferred because of his (vector) font handling ability.

I suppose that this is the reason why Felipe wishes to start with PostScript (or EPS).

tiziano ______________________________________ http://digilander.libero.it/tizzziano/