[cairo] Embeding JPG in PDF

Behdad Esfahbod behdad at behdad.org
Mon Jan 8 17:18:10 PST 2007


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.

I see these options:

  - Tell eog and application developers to use something other than
cairo to create their PDFs, to embed JPG directly.  Not good, specially
because the Gtk+ print API is totally based on cairo.

  - Add API to cairo to set "quality" on embedded images.  Anything
other than the "perfect" setting will cause JPGs to be emitted instead
of PNGs.  Needs cairo to depend on libjpg, add new API, a bit clumsy,
and is still lossy because a the image will be re-encoded to JPG instead
of using the original JPG.

  - An in-between solution: Add PDF-specific API to cairo, ala
cairo_ps_surface_dsc_comment(), to embed arbitrary objects into the PDF,
and some other API to use them.  For example as a source pattern.  Not
very cairoesque, and not clear how feasible this is.

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.

Let discussion begin.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=394260

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list