Hm. What I meant was, is there a way to do that without rasterization? I intended to use this for rendering posters, where a 3MB 2000dpi image is less desirable than a few line-drawing commands. It would be lovely to be able to rotate and scale PDFs with slidehsow/pict without converting them to bitmaps first, but doing so in a portable way.
Maybe it's best to provide both ways? Making a pdf-page->bitmap% function with the kosher bitmap% get-handle way, and a render-pdf-to-dc! function. I'll investigate this. 8 hours ago, Jens Axel Søgaard wrote: > 2012/5/8 Michael W <mwil...@uccs.edu>: > > Sure, but I mean, is there a better way to get at a dc<%>'s cairo > > context than (require racket/draw/private/local) ? From what I > > understand, those areas aren't meant to be used by third-party > > libraries, and definitely not by planet packages. Not all dc<%>s > > are even backed by cairo contexts... > > I believe you want get-handle. It will give you the surface of a bitmap, > and you can then get a context. > > (let* ([bitmap (make-bitmap WIDTH HEIGHT)] ; works > [filename > "/Users/soegaard/Dropbox/GitHub/this-and-that/racket-poppler/bla.pdf"] > [document (poppler_document_new_from_file (string-append > "file:" filename) #f #f)] > [page (poppler_document_get_page document 0)] > [surface (send bitmap get-handle)] > [context (cairo_create surface)]) > (cairo_scale context 2.0 2.0) > (poppler_page_render page context) > (make-object image-snip% bitmap)) > > This example is from > > https://github.com/soegaard/this-and-that/blob/master/racket-poppler/racket-poppler.rkt > > /Jens Axel > > > > > 16 minutes ago, Eli Barzilay wrote: > >> Three hours ago, Michael W wrote: > >> > > >> > 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. > >> > >> I don't know about "hacky" -- it just sounds like it'll invoke the > >> library for every redraw, which would be overall slower than going > >> through a bitmap that saves the results. > >> > > ____________________ > > Racket Users list: > > http://lists.racket-lang.org/users > ____________________ Racket Users list: http://lists.racket-lang.org/users