How can I create a multipage PDF?

  • Hi,

    Almost four years ago I moved from Cocoa to scripting languages,
    tcl/tk, python/tkinter, and wxpython.

    I decided to try to get back into cocoa by updating some of
    my old projects for Leopard.

    One project that interested me was my "ImageBrowser" a program
    that could display/slideshow directories of images.

    I decided to enhance the app so it could display "Graphic
    Novels" (aka comics).

    After eight or nine days of beating my head against the
    wall, this morning I was able to generate a universal
    binary of the rascal and I can drag a cbr/cbz file onto
    the window or icon and have instant viewing :)

    I recently bought an Irex Iliad ebook reader and thought
    it would be nice to be able to view "graphic novels" on
    the device.

    So...

    In my cocoa app ImageBrowser I have a NSArray of path
    names to images in the file systems.

    Is there a neat way to use the array to generate a
    multipage pdf document?

    Keeping the app  as a universal binary would be a plus.

    Thanks for any hints, pointers, etc...

    Jerry
  • On Dec 10, 2007, at 7:08 PM, Jerry LeVan wrote:

    > Is there a neat way to use the array to generate a
    > multipage pdf document?

    On Leopard PDFPage sports an initWithImage: initializer which you can
    use to easily create PDFPages from your graphics that you then add to
    a PDFDocument that you initialized with a simple init:

    If you want to do it on Tiger it is all going to be a bit more work.

    -António

    ----------------------------------------------------
    There is a world of difference between
    searching for happiness and choosing
    to be happy.
    ----------------------------------------------------
  • On Dec 11, 2007, at 3:06 PM, Jerry LeVan wrote:

    > How can I reduce the size of the pdf generated by the following code ?

    From PDFDocument.h:

    // Methods to record the current state of the PDFDocument as data or a
    file.  Passing a QuartzFilter object in the
    // options dictionary with the key @"QuartzFilter" will allow you to
    have the filter applied when saving the PDF.

    So I guess you could adjust your code to pass in a quartz filter that
    reduces the file size:
    [myBook writeToFile:@"/Users/jerry/Desktop/Book.pdf"
    withOptions:optionsDictWithQuartzFilter];

    I know next to nothing about Quartz filters, all I can say is that the
    following seems to work:

    NSArray *filters = [QuartzFilterManager filtersInDomains:[NSArray
    arrayWithObject:@"QuartzFilterPDFWorkflowDomain"]];
    QuartzFilter *f = [filters objectAtIndex:6];
    [optionsDictWithQuartzFilter setObject:f forKey:@"QuartzFilter"];

    But I'd be surprised if this is the best - or even a good - way to get
    at the Reduce File Size filter. (This filter works by downsampling
    images in a PDF file and turning them into jpg, if I am not mistaken,
    so it should produce good results with the files you are targeting. Of
    course, the image quality will suffer.

    -António

    -----------------------------------------
    Forgiveness is not an occasional act;
    it is a permanent attitude.

    --Martin Luther King, Jr
    -----------------------------------------
previous month december 2007 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