server-side images

4 views
Skip to first unread message

Harri

unread,
Jun 27, 2011, 12:41:33 AM6/27/11
to Cartagen
Hi all,

Looking for ideas to render the cartagen map to a file to be embedded
into a PDF automatically on the server-side. Khtml2png2 does not work
as khtml does not support HTML5 canvas. Other traditional OSM engines
do not support GSS.

Any ideas?

Br,
Harri

Tobias Sauerwein

unread,
Jun 27, 2011, 3:29:11 AM6/27/11
to cartag...@googlegroups.com
Hi Harri,

you could use Webkit and directly export to a PDF:
http://code.google.com/p/wkhtmltopdf/

Tobias

Jeffrey Warren

unread,
Jun 27, 2011, 10:59:27 AM6/27/11
to cartag...@googlegroups.com
well since it generates all graphics locally, maybe it'd be best to snapshot the current view and send it to the server for inclusion in a PDF. You can use

$C.to_data_url()

to get a PNG of the current view, in data_url (base64 encoded, which you can decode to get the .png file)

you could submit this as part of a GET or POST request to the server, along with any other relevant data, and it could embed it in a PDF and return. I've done this once before on a different project and it works surprisingly well.

There's also a (i'm pretty sure) non-functional "to_print_data_url()" function which I had tried to get to render a much larger "virtual" canvas, for print quality stuff. http://cartagen.org/api/index.html - maybe you could get it working. I think it tried to change the canvas size, render to data url, than change it again to its original size without actually drawing it to the screen -- in between frames.

The final option is to try to code an SVG or even PDF renderer as a swap-out module for the Canvas library. Architecturally this should be possible, but i never got around to coding it. Oh well.

Good luck!!
Jeff


--
You received this message because you are subscribed to the Google Groups "Cartagen" group.
To post to this group, send email to cartag...@googlegroups.com.
To unsubscribe from this group, send email to cartagen-dev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cartagen-dev?hl=en.


Harri

unread,
Jul 8, 2011, 1:19:12 PM7/8/11
to Cartagen
I tried the webkit approach, it prematurely renders the page. However
there is an option to say that until document readyState is something
it doesn't start rendering but it didn't seem to work. But will look
into that later.

Harri

On Jun 27, 5:59 pm, Jeffrey Warren <j...@unterbahn.com> wrote:
> well since it generates all graphics locally, maybe it'd be best to snapshot
> the current view and send it to the server for inclusion in a PDF. You can
> use
>
> $C.to_data_url()
>
> to get a PNG of the current view, in data_url (base64 encoded, which you can
> decode to get the .png file)
>
> you could submit this as part of a GET or POST request to the server, along
> with any other relevant data, and it could embed it in a PDF and return.
> I've done this once before on a different project and it works surprisingly
> well.
>
> There's also a (i'm pretty sure) non-functional "to_print_data_url()"
> function which I had tried to get to render a much larger "virtual" canvas,
> for print quality stuff.http://cartagen.org/api/index.html- maybe you
> could get it working. I think it tried to change the canvas size, render to
> data url, than change it again to its original size without actually drawing
> it to the screen -- in between frames.
>
> The final option is to try to code an SVG or even PDF renderer as a swap-out
> module for the Canvas library. Architecturally this should be possible, but
> i never got around to coding it. Oh well.
>
> Good luck!!
> Jeff
>
>
>
> On Mon, Jun 27, 2011 at 3:29 AM, Tobias Sauerwein <to.s...@gmail.com> wrote:
> > Hi Harri,
>
> > you could use Webkit and directly export to a PDF:
> >http://code.google.com/p/**wkhtmltopdf/<http://code.google.com/p/wkhtmltopdf/>
>
> > Tobias
>
> > Harri wrote (27.06.2011 06:41):
>
> >  Hi all,
>
> >> Looking for ideas to render the cartagen map to a file to be embedded
> >> into a PDF automatically on the server-side. Khtml2png2 does not work
> >> as khtml does not support HTML5 canvas. Other traditional OSM engines
> >> do not support GSS.
>
> >> Any ideas?
>
> >> Br,
> >> Harri
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Cartagen" group.
> > To post to this group, send email to cartag...@googlegroups.com.
> > To unsubscribe from this group, send email to cartagen-dev+unsubscribe@**
> > googlegroups.com <cartagen-dev%2Bunsu...@googlegroups.com>.
> > For more options, visit this group athttp://groups.google.com/**
> > group/cartagen-dev?hl=en<http://groups.google.com/group/cartagen-dev?hl=en>
> > .

Harri

unread,
Jul 30, 2011, 8:51:25 PM7/30/11
to Cartagen
Okay... phantomjs did the job out of the box:
http://code.google.com/p/phantomjs/wiki/QuickStart#Rendering

Harri

On Jul 8, 8:19 pm, Harri <harri.hoht...@gmail.com> wrote:
> I tried the webkit approach, it prematurely renders the page. However
> there is an option to say that until document readyState is something
> it doesn't start rendering but it didn't seem to work. But will look
> into that later.
>
> Harri
>
> On Jun 27, 5:59 pm, Jeffrey Warren <j...@unterbahn.com> wrote:
>
>
>
>
>
>
>
> > well since it generates all graphics locally, maybe it'd be best to snapshot
> > the current view and send it to the server for inclusion in a PDF. You can
> > use
>
> > $C.to_data_url()
>
> > to get a PNG of the current view, in data_url (base64 encoded, which you can
> > decode to get the .png file)
>
> > you could submit this as part of a GET or POST request to the server, along
> > with any other relevant data, and it could embed it in a PDF and return.
> > I've done this once before on a different project and it works surprisingly
> > well.
>
> > There's also a (i'm pretty sure) non-functional "to_print_data_url()"
> > function which I had tried to get to render a much larger "virtual" canvas,
> > for print quality stuff.http://cartagen.org/api/index.html-maybe you
Reply all
Reply to author
Forward
0 new messages