Pascal postscript reading library

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Pascal postscript reading library

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Florian Klämpfl
Felipe Monteiro de Carvalho schrieb:

> 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
On Sun, Apr 20, 2008 at 6:42 AM, Florian Klaempfl
<[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Ricardo Aguiar
In reply to this post by Felipe Monteiro de Carvalho

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.

On Saturday 19 April 2008, Felipe Monteiro de Carvalho wrote:

> 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,


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
Hello,

On Mon, Apr 21, 2008 at 5:30 AM, Ricardo Aguiar <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
In reply to this post by Florian Klämpfl
On Sun, Apr 20, 2008 at 6:42 AM, Florian Klaempfl
<[hidden email]> wrote:
>  PS is really complex, it's a full programming language after all. I would
> consider a Ghostscript wrapper.

The company that sells Ghostscript refused to sell it to my company
due to insuficiente selling volume. Looks like this isn't an option.

--
Felipe Monteiro de Carvalho
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Ricardo Aguiar
In reply to this post by Felipe Monteiro de Carvalho

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.

On Monday 21 April 2008, Felipe Monteiro de Carvalho wrote:
> 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.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Krishna-33
In reply to this post by Felipe Monteiro de Carvalho
On Sun, Apr 20, 2008 at 3:30 AM, Felipe Monteiro de Carvalho
<[hidden email]> wrote:
> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
On Wed, Apr 23, 2008 at 4:32 AM, Krishna <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Marc Santhoff
Hi Felipe,

Am Mittwoch, den 23.04.2008, 07:29 -0300 schrieb Felipe Monteiro de Carvalho:
> 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


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Krishna-33
In reply to this post by Felipe Monteiro de Carvalho
On Wed, Apr 23, 2008 at 3:59 PM, Felipe Monteiro de Carvalho
<[hidden email]> wrote:

> On Wed, Apr 23, 2008 at 4:32 AM, Krishna <[hidden email]> 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.

>  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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
In reply to this post by Marc Santhoff
On Wed, Apr 23, 2008 at 8:19 AM, Marc Santhoff <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
In reply to this post by Krishna-33
On Wed, Apr 23, 2008 at 8:35 AM, Krishna <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Marc Santhoff
In reply to this post by Felipe Monteiro de Carvalho
Am Mittwoch, den 23.04.2008, 08:36 -0300 schrieb Felipe Monteiro de
Carvalho:

> On Wed, Apr 23, 2008 at 8:19 AM, Marc Santhoff <[hidden email]> 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


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Funky Beast
In reply to this post by Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote:

> On Wed, Apr 23, 2008 at 4:32 AM, Krishna <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re: Pascal postscript reading library

Felipe Monteiro de Carvalho
On Wed, Apr 23, 2008 at 10:04 AM, Funky Beast <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Funky Beast
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Luiz Americo Pereira Camara-2
In reply to this post by Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote:

> On Wed, Apr 23, 2008 at 4:32 AM, Krishna <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Pascal postscript reading library

Marc Weustink
In reply to this post by Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote:

> On Wed, Apr 23, 2008 at 4:32 AM, Krishna <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Re: Pascal postscript reading library

Graeme Geldenhuys-2
In reply to this post by Funky Beast
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/


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
12