PDF to image creation in ios

后端 未结 2 591
终归单人心
终归单人心 2021-01-03 15:13

Hi Everyone I am trying to create PNG(thumbnail) images from the pdf for my app for that i used couple of answers from the stackoverflow below code is i am using `-

相关标签:
2条回答
  • 2021-01-03 16:00

    A loop for thousand pages means you alloc memory for each page process and that chunk of memory is never reused until method ends. Obj-C memory management works that way, with an effective release of memory after each loop.

    If you want to reuse memory for each iteration, use an independent NSAutoreleasePool

    for(int i = 0; i < totalNum; i++ ) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        ... .... (process page ... ) ...
        [pool release];
    }
    

    Or, in the case you are using ARC:

    for(int i = 0; i < totalNum; i++) {
        @autoreleasePool {
            .... (... process page ... ) ....
        }
    }
    
    0 讨论(0)
  • 2021-01-03 16:03

    Check out this open source project; they're doing quite a good job of rending the PDF into a UIImage. https://github.com/mindbrix/UIImage-PDF

    0 讨论(0)
提交回复
热议问题