[GRASS-dev] Re: [GRASS-user] Vector drawings in PDF -> converting them

John Tull wrote:
> I found this with a search of freshmeat.net. Perhaps it will work,
> and free. Let us know.
>
> http://www.pstoedit.net/

Kurt Heston wrote:

Excellent! Works flawlessly. Just a little experimenting yielded
this command:

pstoedit.exe -f dxf_s:-splineaspolyline roads.pdf roads.dxf

Without the "-splineaspolyline" argument the DXF looks just like the
other conversions that didn't work.

I now have a solution with the right licensing model. Thanks for the
suggestion!

(The code is GPL2)

Display of PS/EPS in a GRASS monitor-
looking at src/drvsampl.cpp and drvsampl.h, the primitive commands are
very close to d.graph's set (which reflects grass's raster graphics
lib): move to, line to, rectangle, set line color, set fill color, etc.
so it would probably be fairly simple for someone to write a d.graph
input file plugin for pstoedit, or incorporate the PS
reading/sanitizing code to let d.graph render PS files in the xmon.
(e.g. .eps logo)
Perhaps wxPython's GUI canvas is able to directly render PS already???
(no idea) If so this would be a lower priority, but still interesting.

Import as vector map-
Translating moveto and lineto commands into coordinates for standard
GRASS ascii format (for v.in.ascii) with a pstoedit plugin would be a
little more work, but fairly trivial. And using their code to make a
v.in.ps module seems feasible too if someone wished to make that.
(then like DXF you'd use v.transform to adjust from XY to map coords)

Certainly converting PDF or PS to another vector format with a
rasterization step degrades the data unnecessarily.

Another tool which could be useful is pdftk. If you uncompress the PDF
with that you get text-editor access to the PostScript within, and then
it's just translating ps draw commands to coordinates.
It's highly useful for other PDF tasks too.
  http://www.pdfhacks.com/pdftk/

Hamish

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Hamish wrote:

> > I found this with a search of freshmeat.net. Perhaps it will work,
> > and free. Let us know.
> >
> > http://www.pstoedit.net/

Kurt Heston wrote:
> Excellent! Works flawlessly. Just a little experimenting yielded
> this command:
>
> pstoedit.exe -f dxf_s:-splineaspolyline roads.pdf roads.dxf
>
> Without the "-splineaspolyline" argument the DXF looks just like the
> other conversions that didn't work.
>
> I now have a solution with the right licensing model. Thanks for the
> suggestion!

(The code is GPL2)

Display of PS/EPS in a GRASS monitor-
looking at src/drvsampl.cpp and drvsampl.h, the primitive commands are
very close to d.graph's set (which reflects grass's raster graphics
lib): move to, line to, rectangle, set line color, set fill color, etc.
so it would probably be fairly simple for someone to write a d.graph
input file plugin for pstoedit, or incorporate the PS
reading/sanitizing code to let d.graph render PS files in the xmon.
(e.g. .eps logo)

Not quite. The PS/PDF moveto/lineto commands construct paths which are
subsequently either stroked or filled, while the GRASS equivalents
automatically stroke the path.

To display PS/PDF vector data using the GRASS display system, you
would need to accumulate the moveto/lineto commands into a buffer,
then either "replay" the data using R_move_abs/R_cont_abs or use it to
construct a polygon to be filled with R_polygon_abs.

In the case of filling, there may be issues with complex areas. PS/PDF
provides a choice of non-zero and even-odd winding rules (fill and
eofill operators respectively), while GRASS only provides even-odd.

Perhaps wxPython's GUI canvas is able to directly render PS already???
(no idea) If so this would be a lower priority, but still interesting.

Processing arbitrary PostScript is complex enough that all practical
options involve Ghostscript. This is true whether you're rasterising
or converting to some other vector format.

The latter case normally involves using one of Ghostscript's vector
output drivers, e.g. PCL or PDF, or even the "pswrite" driver (which
outputs relatively "flat" PostScript using a limited set of
operators).

--
Glynn Clements <glynn@gclements.plus.com>