[Geoserver-devel] geotools/geoserver iText and geoPDF

Hi List, Hi Jody

First of all, sorry for cross-posting!

Last Night I had a look at the iText Project [1] Jody has mentioned and I have to dive deeper to get a clue what it does and which part of the API is currently used by geotools/geoserver.

What I like to get is a pdf file where the user could use (but not required) the free terrago toolbar [2] to measure distances and areas and type lat/lon coordinates to jump to locations within the pdf. But it is required to have CRS information about the data/content within the document. In addition it would be great to have layers in the hierarchy view (Index) and search capabilities on the feature content (attribute values).

But however, would’t that be nice features for all geoserver/geotools folks and end-users to get a ready to go pdf for the field and have these capabilities.

Maybe some of you could point me to the code where the pdf stuff is taking place … I’m going to read the adope pdf documentation [4] to find a hint if some TAGs are missed to act like a geopdf. And properly it’s already supported by iText to create the meta information. An other relevant documentation is “PDF Geo-registration Encoding Best Practice Version 2.2” at OGC standards best practices home [3].

Do you think we could create an enhancement in geotools/geoserver for that? Or can we just discuss to find a way how to solve it.

Thanks for any advice and any suggestions.

Frank

[1] iText Project home http://itextpdf.com/
[2] free toolbar available at http://www.terragotech.com/products/terrago-toolbar/ (registration required)
[3] ogc best practices geo referenced pdf : http://portal.opengeospatial.org/files/?artifact_id=40537
[4] Adope PDF Reference : http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf

We should probably stick on the user list; unless we are talking about adding code - I would love to see a geopdf module for geotools.

Here is some code to set up an iText Graphics:

And to print use the normal streaming renderer examples:

I filled in some of the details on that page about printing; try out the code and correct as needed.

Jody

On 01/02/2011, at 6:38 PM, Frank Gasdorf wrote:

Hi List, Hi Jody

First of all, sorry for cross-posting!

Last Night I had a look at the iText Project [1] Jody has mentioned and I have to dive deeper to get a clue what it does and which part of the API is currently used by geotools/geoserver.

What I like to get is a pdf file where the user could use (but not required) the free terrago toolbar [2] to measure distances and areas and type lat/lon coordinates to jump to locations within the pdf. But it is required to have CRS information about the data/content within the document. In addition it would be great to have layers in the hierarchy view (Index) and search capabilities on the feature content (attribute values).

But however, would’t that be nice features for all geoserver/geotools folks and end-users to get a ready to go pdf for the field and have these capabilities.

Maybe some of you could point me to the code where the pdf stuff is taking place … I’m going to read the adope pdf documentation [4] to find a hint if some TAGs are missed to act like a geopdf. And properly it’s already supported by iText to create the meta information. An other relevant documentation is " at OGC standards best practices home [3].

Do you think we could create an enhancement in geotools/geoserver for that? Or can we just discuss to find a way how to solve it.

Thanks for any advice and any suggestions.

Frank

[1] iText Project home http://itextpdf.com/
[2] free toolbar available at http://www.terragotech.com/products/terrago-toolbar/ (registration required)
[3] ogc best practices geo referenced pdf : http://portal.opengeospatial.org/files/?artifact_id=40537
[4] Adope PDF Reference : http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf

On Tue, Feb 1, 2011 at 9:38 AM, Frank Gasdorf
<fgdrf@anonymised.com> wrote:

Hi List, Hi Jody
First of all, sorry for cross-posting!

Last Night I had a look at the iText Project [1] Jody has mentioned and I
have to dive deeper to get a clue what it does and which part of the API is
currently used by geotools/geoserver.
What I like to get is a pdf file where the user could use (but not required)
the free terrago toolbar [2] to measure distances and areas and type lat/lon
coordinates to jump to locations within the pdf. But it is required to have
CRS information about the data/content within the document. In addition it
would be great to have layers in the hierarchy view (Index) and search
capabilities on the feature content (attribute values).
But however, would't that be nice features for all geoserver/geotools folks
and end-users to get a ready to go pdf for the field and have these
capabilities.
Maybe some of you could point me to the code where the pdf stuff is taking
place ... I'm going to read the adope pdf documentation [4] to find a hint
if some TAGs are missed to act like a geopdf. And properly it's already
supported by iText to create the meta information. An other relevant
documentation is "PDF Geo-registration Encoding Best Practice Version
2.2" at OGC standards best practices home [3].
Do you think we could create an enhancement in geotools/geoserver for that?

I don't know, didn't had the time to investigate the links you provided.
Howerver, the code that generates PDF in GeoServer is here:
http://svn.codehaus.org/geoserver/trunk/src/wms/src/main/java/org/geoserver/wms/map/PDFMapResponse.java

Basically we ask iText to give up a Graphics2D object and then we draw
on top of it as if it was a java2d one.

That does not give an occasion to do anything in between layers
getting rendered.
I guess one could split the map into n single maps, yet that would break
labeling solid (as it has to happen at the end of the rendering to
have all labels
conflict resolve with each other and stay on top).
That too can be handled somehow but it would require splitting the styles
into components with text symbolizers and components without....

As for setting in the necessary metadata, I hope iText provides the
necessary support for that (but I'm confident it might)

Cheers
Andrea

PS: ah, another possible hack is to create a custom label cache that
just wraps the standard one. This is because the label cache is informed
on layers starting and stopping being rendered.
Yet another possibility would be to make streaming renderer subclassable,
but it's not on purpose, not really though to be a base class

--
Ing. Andrea Aime
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------

Just to follow up andrea's ideas.

In udig we make a custom label cache and throw it at several streaming renderers (so they can render in different threads) - so the idea of a custom label cache works very well.

We also do a trick of increasing the page resolution; and then also using a visitor to edit the styles (so lines and fonts are bigger); and then rescale that output down to the final page size. This results in a larger; but higher quality pdf.

Jody

On 02/02/2011, at 6:36 PM, Andrea Aime wrote:

On Tue, Feb 1, 2011 at 9:38 AM, Frank Gasdorf
<fgdrf@anonymised.com> wrote:

Hi List, Hi Jody
First of all, sorry for cross-posting!

Last Night I had a look at the iText Project [1] Jody has mentioned and I
have to dive deeper to get a clue what it does and which part of the API is
currently used by geotools/geoserver.
What I like to get is a pdf file where the user could use (but not required)
the free terrago toolbar [2] to measure distances and areas and type lat/lon
coordinates to jump to locations within the pdf. But it is required to have
CRS information about the data/content within the document. In addition it
would be great to have layers in the hierarchy view (Index) and search
capabilities on the feature content (attribute values).
But however, would't that be nice features for all geoserver/geotools folks
and end-users to get a ready to go pdf for the field and have these
capabilities.
Maybe some of you could point me to the code where the pdf stuff is taking
place ... I'm going to read the adope pdf documentation [4] to find a hint
if some TAGs are missed to act like a geopdf. And properly it's already
supported by iText to create the meta information. An other relevant
documentation is "PDF Geo-registration Encoding Best Practice Version
2.2" at OGC standards best practices home [3].
Do you think we could create an enhancement in geotools/geoserver for that?

I don't know, didn't had the time to investigate the links you provided.
Howerver, the code that generates PDF in GeoServer is here:
http://svn.codehaus.org/geoserver/trunk/src/wms/src/main/java/org/geoserver/wms/map/PDFMapResponse.java

Basically we ask iText to give up a Graphics2D object and then we draw
on top of it as if it was a java2d one.

That does not give an occasion to do anything in between layers
getting rendered.
I guess one could split the map into n single maps, yet that would break
labeling solid (as it has to happen at the end of the rendering to
have all labels
conflict resolve with each other and stay on top).
That too can be handled somehow but it would require splitting the styles
into components with text symbolizers and components without....

As for setting in the necessary metadata, I hope iText provides the
necessary support for that (but I'm confident it might)

Cheers
Andrea

PS: ah, another possible hack is to create a custom label cache that
just wraps the standard one. This is because the label cache is informed
on layers starting and stopping being rendered.
Yet another possibility would be to make streaming renderer subclassable,
but it's not on purpose, not really though to be a base class

--
Ing. Andrea Aime
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------

On Wed, Feb 2, 2011 at 1:22 PM, Jody Garnett <jody.garnett@anonymised.com> wrote:

Just to follow up andrea's ideas.

In udig we make a custom label cache and throw it at several streaming renderers (so they can render in different threads) - so the idea of a custom label cache works very well.

Right, did not think about it, that also solves the problem of having
all the labels keep on conflict resolutiong with each other,
one just has to kick the label cache drawing when all the layers have
done rendering

We also do a trick of increasing the page resolution; and then also using a visitor to edit the styles (so lines and fonts are bigger); and then rescale that output down to the final page size. This results in a larger; but higher quality pdf.

That one is no more necessary, we do have dpi control in the renderer
now (have been for quite some time)

Cheers
Andrea

--
Ing. Andrea Aime
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584962313
fax: +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------