[cairo] Embeding JPG in PDF

Kristian Høgsberg krh at bitplanet.net
Mon Jan 8 18:52:25 PST 2007


On 1/8/07, Behdad Esfahbod <behdad at behdad.org> wrote:
> Hi,
>
> So, there's this bug against eog (GNOME image viewer) [1] about images
> printed to PDF are huge.  The reason of course is that cairo embeds
> images as PNG.  We need to find a solution to this.
...
> My personal preference is to add just enough API to cairo-pdf.h that a
> toolkit like pdftk can /integrate/ with cairo, to produce more advanced
> PDF documents.  That's what we do for text: delegate to pangocairo.

My thoughts about this is that we could add a function like

 cairo_surface_t
 cairo_pdf_surface_create_from_jpeg(const char *filename);

(plus a stream version) that reads in the jpeg and just stores the
data.  If the surface is used in a pdf surface we just emit the jpeg
data directly as a pdf object and use that.  If we need the pixels
(for example, if it is used with an image surface) we decode the jpeg
data and convert it to an image surface.  Of course, cairo then needs
to link to libjpeg.

Leaving the door open for integration with toolkits such as pdftk is
nice in that it's a catch-all solution, but if that's the only way, it
now requires significantly more pdf knowledge on the application
writers part to embed the jpeg.

cheers,
Kristian


More information about the cairo mailing list