making small pdfs

  • My experience so far in generating pdfs in Cocoa or Quartz is that the
    pdfs generated either through NSPrinterOperation or Quartz calls are
    very large.

    There does not seem to be any documentation on how to take a compressed
    jpg, draw it into a pdf and then get the benefit of the jpg compression
    to make the resulting pdf a smaller file size.

    If you take create an NSImage with a Jpg and then draw it into a pdf,
    the result file depending on resolution is bigger when saving the pdf
    by a factor of at least 10.  ie a 30k jpg becomes 300k pdf.  I believe
    I understand why, the compression from the jpg is lost when the NSImage
    is drawn to a pdf context.  ie bits and colors are saved without
    compression as the same bits and colors.

    Does anyone have any pointers in either in Quartz or Cocoa to use an
    approved compression so that say I can embed the jpg inside the pdf and
    when Acrobat or Preview knows and renders the image. The intent is to
    scan a document or documents and then save the resulting scan as a pdf
    which contains an embedded jpg of the scanned document.  Each page
    would have an embedded jpg of the pdf page scanned.

    I see references to CGPDFContextStream but I don't see where you can
    control the compression factors of the jpg.

    Anyone have a couple lines of code, or api call that can point me in
    the right directions?

    Jim
  • > Anyone have a couple lines of code, or api call that can point me in
    > the right directions?

    Honestly, for this, you might be better off creating the PDF directly
    yourself. The spec is available at Adobe.com, and you're probably only
    talking a very few pages of code.

    --
    Scott Ribe
    <scott_ribe...>
    http://www.killerbytes.com/
    (303) 722-0567 voice
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today