func drawOnPDF(path: String)
{
// Get existing Pdf reference
let pdf = CGPDFDocumentCreateWithURL(NSURL(fileURLWithPath: path))
// Get page count of pdf, so we can loop through pages and draw them accordingly
let pageCount = CGPDFDocumentGetNumberOfPages(pdf);
// Write to file
UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil)
// Write to data
// var data = NSMutableData()
// UIGraphicsBeginPDFContextToData(data, CGRectZero, nil)
for index in 1...pageCount {
let page = CGPDFDocumentGetPage(pdf, index)
let pageFrame = CGPDFPageGetBoxRect(page, kCGPDFMediaBox)
UIGraphicsBeginPDFPageWithInfo(pageFrame, nil)
var ctx = UIGraphicsGetCurrentContext()
// Draw existing page
CGContextSaveGState(ctx);
CGContextScaleCTM(ctx, 1, -1);
CGContextTranslateCTM(ctx, 0, -pageFrame.size.height);
CGContextDrawPDFPage(ctx, page);
CGContextRestoreGState(ctx);
// Draw image on top of page
var image = UIImage(named: "signature3")
image?.drawInRect(CGRectMake(100, 100, 100, 100))
// Draw red box on top of page
//UIColor.redColor().set()
//UIRectFill(CGRectMake(20, 20, 100, 100));
}
UIGraphicsEndPDFContext()
}
मेरे समस्या पीडीएफ छवि में बदलने का है, लेकिन कैसे दृश्य में छवि को खोलने के लिए और फिर बाएं, दाएं स्वाइप करें, ऊपर और नीचे कैसे संभवConvert पीडीएफ
अच्छा समाधान पीडीएफ छवि में बदलने स्विफ्ट में .. के लिए :) @bhargav – InsaneCat
जहां सरणी से आता है? यह कैसे काम करता है? – MizAkita