If it's possible to generate a PDF file from a UITableView?

随声附和 提交于 2019-12-05 11:40:16
senthilMuthu

HI , you can convert current view as image through the follwoing code and then you have to use that image to create PDF File through the link

    - (UIImage *)captureView:(UIView *)view {
    CGRect screenRect = [[UIScreen mainScreen] bounds];

    UIGraphicsBeginImageContext(screenRect.size);

    CGContextRef ctx = UIGraphicsGetCurrentContext();
    [[UIColor blackColor] set];
    CGContextFillRect(ctx, screenRect);

    [view.layer renderInContext:ctx];

    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return newImage;
   }
user1806228

To get good quality image,

Use

UIGraphicsBeginImageContextWithOptions(screenRect.size, NO, 0.0) 

instead of

UIGraphicsBeginImageContext(screenRect.size)

@JeffWood: thank a million, for your answer :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!