Create PDF

suggest change
UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, nil);

UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
    
[self drawText];
    
UIGraphicsEndPDFContext();

fileName is the document file where You are going to append or attach

NSString* temporaryFile = @"firstIOS.PDF";
   NSArray *arrayPaths =
   NSSearchPathForDirectoriesInDomains(
                                       NSDocumentDirectory,
                                       NSUserDomainMask,
                                       YES);
   
   NSString *path = [arrayPaths objectAtIndex:0];
   
   NSString* fileName = [path stringByAppendingPathComponent:fileName];

Where drawText is

(void)drawText
{
 NSString* textToDraw = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";

 CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
 
 CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, NULL);
 
 CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
 
 CGRect frameRect = CGRectMake(0, 0, 300, 100);
 
 CGMutablePathRef framePath = CGPathCreateMutable();
 
 CGPathAddRect(framePath, NULL, frameRect);
 
 CFRange currentRange = CFRangeMake(0, 0);
 
 CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
 CGPathRelease(framePath);
 
 CGContextRef currentContext = UIGraphicsGetCurrentContext();
 

 CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity);
 

 CGContextTranslateCTM(currentContext, 0, 450);
 
 CGContextScaleCTM(currentContext, 2, -2);
 
 CTFrameDraw(frameRef, currentContext);
 
 CFRelease(frameRef);

 CFRelease(stringRef);

 CFRelease(framesetter);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


PDF Creation:
* Create PDF

Table Of Contents
12 UIView
15 UIColor
26 UIImage
28 CALayer
30 NSDate
40 iBeacon
47 PDF Creation
49 NSTimer
79 NSURL
87 AWS SDK
96 NSData
101 Segues
104 EventKit
105 NSBundle
106 SiriKit
111 StoreKit
117 3D Touch
119 Keychain
122 Block
141 AirDrop
144 UISlider
145 Carthage
146 HealthKit
151 plist
157 MVVM
164 UIPhoenix
166 Simulator
168 NSArray
169 OpenGL
175 Core Data
179 MyLayout
180 UIFont
189 Security
200 Codable