Paste number 16841: PDFDocument sucks

Paste number 16841: PDFDocument sucks
Pasted by: Bardology
When:3 years, 4 months ago
Share:Tweet this! | http://paste.lisp.org/+CZT
Channel:#macdev
Paste contents:
Raw Source | XML | Display As
    id statementView = [JLDocumentView invoice:@"189280"];
    int page, numberOfPages = [[statementView delegate] numberOfPages];

    NSRect pageRect = [statementView rectForPage:1];
    NSData *pdfData = [statementView dataWithPDFInsideRect:pageRect];
    PDFDocument *pdfDoc = nil;
    PDFPage *pdfPage = nil;

    PDFDocument *pdf = [[[PDFDocument alloc] initWithData:pdfData] autorelease];
    NSLog(@"Created Document");
    
    for (page = 2; page <= numberOfPages; page++) {
        pageRect = [statementView rectForPage:page];
        NSLog(@"1. Created Rect");
        
        pdfData = [statementView dataWithPDFInsideRect:[statementView frame]];
        NSLog(@"2. Created Data");
        
        pdfDoc = [[[PDFDocument alloc] initWithData:pdfData] autorelease];
        NSLog(@"3. Created Document");
        
        pdfPage = [pdfDoc pageAtIndex:0];
        NSLog(@"4. Created Page");
        
        [pdf insertPage:pdfPage atIndex:page - 1];
        NSLog(@"5. Inserted Page"); // <- Hella Slow!
    }
    [pdf writeToFile:@"/Users/jbard/Desktop/Test0.pdf"];
    NSLog(@"File written");

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.