如何实现pdf编辑器

ned*_*esh 8 pdf xcode ios swift

我正在处理一个应用程序,我正在使用pdfkit它,我应该有能力读取pdf文件并编辑它们.我发现iOS有一个编辑器,如下图所示 在此输入图像描述

有没有办法在我的应用程序中实现这样的东西?我应该搜索什么?

感谢任何帮助.谢谢

Sug*_*nya -1

func createAndEditPDF() {

        let pdfURL = NSURL(fileURLWithPath: self.selectedFile.fileURL); // URL of the existing PDF 
        if let pdf:CGPDFDocument = CGPDFDocument(pdfURL as CFURL) { // Create a PDF Document
            let _newURL = "\(documentFolderPath)/\(self.selectedFile.name)"; // New URL to save editable PDF
            let _url = NSURL(fileURLWithPath: _newURL)
            var _mediaBox:CGRect = CGRect(x: 0, y: 0, width: pageWidth, height: pageHeight); // mediabox which will set the height and width of page
            let _writeContext = CGContext(_url, mediaBox: &_mediaBox, nil) // get the context

            //Run a loop to the number of pages you want
            for i in 0..<self.pages.count
            {
                if let _page = pdf.page(at: self.pages[i]) { // get the page number
                    var _pageRect:CGRect = page.getBoxRect(CGPDFBox.mediaBox) // get the page rect 
                    _writeContext!.beginPage(mediaBox: &_pageRect); // begin new page with given page rect
                    _writeContext!.drawPDFPage(_page); // draw content in page
                    _writeContext!.endPage(); // end the current page
                }
            } 
        }
    }
Run Code Online (Sandbox Code Playgroud)