Create PDF from Image iOS
I am trying to create a pdf of an image that I have now loaded into an image view. I think my code is correct, but when I check the document folder on the simulator, nothing appears. Any ideas? Here is the code related to my botton:
@IBAction func saveToPdf(sender: AnyObject) {
var fileName:String = "new.pdf"
var rect = CGRectMake(0, 0, 850, 1100)
var path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask, true)[0] as String
var pdfPath = path.stringByAppendingPathComponent(fileName)
UIGraphicsBeginPDFContextToFile(pdfPath, CGRectZero, nil)
UIGraphicsBeginPDFPageWithInfo(rect, nil)
var currentContext:CGContextRef = UIGraphicsGetCurrentContext()
imageView.image?.drawInRect(rect)
UIGraphicsEndPDFContext()
}
+3
source to share
No one has answered this question yet
Check out similar questions: