mapfish / mapfish-print

A component of MapFish for printing templated cartographic maps. This module is the Java serverside module.
http://mapfish.github.io/mapfish-print-doc/
BSD 2-Clause "Simplified" License
184 stars 417 forks source link

dataurl in styles, externalgraphics #398

Open mdrbrand opened 8 years ago

mdrbrand commented 8 years ago

In openlayers it is allowed to set a dataurl as ExternalGraphic for a pointsymbol. This is not supported yet.

mdrbrand commented 8 years ago

the following works for me

around line 130 in PointRenderer.java

original line: image = PDFUtils.createImage(context, width * f, height * f, new URI(style.getString("externalGraphic")), 0.0f);

Change import com.itextpdf.text.pdf.codec.Base64; .... String src = style.getString("externalGraphic"); Image image=null; if (src.startsWith("data:image/")) { try { final String base64Data = src.substring(src.indexOf(",") + 1); image = Image.getInstance(Base64.decode(base64Data)); //image.scaleAbsolute(width * f, height * f); } catch (Exception e) { context.addError(e); } } else { image = PDFUtils.createImage(context, width * f, height * f, new URI(style.getString("externalGraphic")), 0.0f); }

Exception-handling could be better ...

tsauerwein commented 8 years ago

Thanks for sharing!

KaiVolland commented 7 years ago

Any news on this one? I need this too.

EDIT: I need this feature in v3.