[racket] Snips displaying pdfs

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Mon May 7 16:02:40 EDT 2012

Hi Michael,

It would be great if you turned it into a Planet package. I had no immediate
need for pdfs, so I put it on hold.

The code attached to the old message rendered the pdf into a png on disc,
and then loaded the png as a snip.

Since then Matthew added get-handle to Racket, so now one can render
a pdf directly to a bitmap without touching the disc.

I have uploaded the latest version here:


It needs a bit of work though...

Currently it simply renders the file bla.pdf into a bitmap that
is then displayed in DrRacket.

Note: You need a fairly recent build of DrRacket.
          The latest stable release is not new enough.

/Jens Axel

2012/5/7 Michael W <mwilber at uccs.edu>:
> This is wonderful. Do you mind if I publish a planet package
> using this code?
> 2 months ago on Sunday, Mar 18, 08:29AM, Jens Axel Søgaard wrote:
>> 2012/3/17 Neil Van Dyke <neil at neilvandyke.org>:
>> > Jens Axel Søgaard wrote at 03/17/2012 09:17 AM:
>> >
>> >> Is it possible to display pdfs in snips without converting them to
>> >> bitmaps?
>> > You might be able to implement this using Poppler.
>> >  http://en.wikipedia.org/wiki/Poppler_%28software%29
>> Looks like Poppler is the way to go.
>> I can now open a pdf-file and render it into a cairo_t context.
>> The code is attached. To test that the rendering works,
>> I saved it in a png, and then displayed it in a snip.
>> I am struggling with creating a bitmap directly from the cairo context.
>> Any pointers?
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Jens Axel Søgaard

Posted on the users mailing list.