[racket] Snips displaying pdfs
(sorry; forgot to cc users@)
Done! ...Sort of.
Put a 'test.pdf' in (current-directory) and try this out:
(require slideshow/pict
(planet gcr/pdf-render))
(show-pict (rotate (pdf-page->pict "./test.pdf" 0)
(* 0.25 pi)))
I'm not rasterizing to a bitmap% or anything like that. Instead,
I'm asking poppler to draw directly to the dc<%>'s cairo context
(Eli and Matthew are probably cringing), which means that you can
render to arbitrary dc<%> objects at the cost of being much more
hacky than your version.
Thanks for the code! I see that you've done a lot more work with
the libpoppler bindings on your github page. I'll have to
incorporate that sometime. :)
2 hours ago, Jens Axel Søgaard wrote:
> 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:
>
> https://github.com/soegaard/this-and-that/tree/master/racket-poppler
>
> 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
>